Building from source without root access

Hi,
I would like to install Pytorch from source for CUDA 12.2. It seems that the default python setup.py install commands requires root access as you can see below:

-- Set runtime path of "/home/mahmood/pytorch/torch/test/cuda_vectorized_test" to "$ORIGIN:/usr/local/cuda-12.2/lib64"
-- Set runtime path of "/home/mahmood/pytorch/torch/test/cuda_cudnn_test" to "$ORIGIN:/usr/local/cuda-12.2/lib64"
CMake Error at caffe2/cmake_install.cmake:1866 (file):
  file INSTALL cannot make directory "/usr/lib/python3/dist-packages/caffe2":
  Permission denied.
Call Stack (most recent call first):
  cmake_install.cmake:139 (include)


gmake: *** [Makefile:110: install] Error 1

So, is there anyway to install that for current user? Something like pip --user.

Try changing CMAKE_PREFIX_PATH to a directory that does not require root permission.
Eg. If you’re using conda, export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}

I am not using Conda. The following commands ended with the same error:

CMAKE_PREFIX_PATH=/home/mahmood/pytorch/install
python setup.py clean
python setup.py develop

The output is

CMake Error at caffe2/cmake_install.cmake:1866 (file):
  file INSTALL cannot make directory "/usr/lib/python3/dist-packages/caffe2":
  Permission denied.
Call Stack (most recent call first):
  cmake_install.cmake:139 (include)

Sounds like there is a problem with caffe2.

No, the issue is that no new folders can be created in your current Python env as your user account does not have the right permissions as @trusira also pointed towards.
Either add permissions to the Python env for your user or try to use another virtual env, e.g. conda.

Regardless of using Conda or not using Conda, the CMAKE_PREFIX_PATH should fix the problem but I don’t know why it is ignored. I assume that the default Python env should read that variable and install caffe2 in the local directory.

I had the same problem, starting about a month ago.

I described the line I have comment out here:

Agree with that… Seems that something is hard coded in the CMAKE file list.