We compute the color-singlet and color-octet nonrelativistic QCD (NRQCD) long-distance matrix elements for inclusive production of $P$-wave quarkonia in the framework of potential NRQCD. In this way, the color-octet NRQCD long-distance matrix element can be determined without relying on measured cross section data, which has not been possible so far. We obtain inclusive cross sections of $chi_{cJ}$ and $chi_{bJ}$ at the LHC, which are in good agreement with data. In principle, the formalism developed in this Letter can be applied to all inclusive production processes of heavy quarkonia.