Compile pytorch v1.3.0 from source with CUDA9.0

I want to compile pytorch v1.3.0 from source with specified CUDA version 9.0. However, even I set the CUDA_PATH and CUDA_HOME to /usr/local/cuda-9.0. It always tries to find cuda from the path /usr/local/cuda.


I know the easiest way is to change the symbol link to /usr/local/cuda-9.0, but I don’t have the sudo privilege on my server. Is there any other way ?

This might be tricky, e.g., if tools like nvidia-smi show a newer CUDA version…
You might want to try changing other environment variables like CUDA_BIN_PATH like the cmake docs state: FindCUDA — CMake 3.20.2 Documentation

Additionally to the previous suggestion you could also try to set CUDA_HOME to the desired CUDA toolkit installation.

I tried this, but when I run python setup.py install, it still tries to find cuda in the default folder, i.e. /usr/local/cuda.

According to your advice, I first run export CUDA_HOME="/usr/local/cuda-9.0", then I run python setup.py install. But it still yells this: