I’ve not faced the same error but if installing from source, yes.
It’s documented to manually set CMAKE_PREFIX_PATH before python setup.py install or python setup.py develop: pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration (github.com) 5.