There are a few options there. One is that, if people are growing from clones, the plants are cloned from female plants. That's one thing. Feminized seeds are also available. These are seeds that are produced to only give female offspring.
There are more molecular methods to determine males and females. For example, my lab offers a test that you can test at a very early seedling stage. Generally—and again it's all about the sort of light regime—you can detect males within several weeks of the triggering of flowering, and then they start to produce a different floral structure that can be identified and they can be removed or....