Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to install pytorch from source. The reason why I am doing this (instead of just pip install pytorch ) is because I need the sm_86 support for my GPU (NVIDIA GTX 3060 Ti) and so I have set the TORCH_CUDA_ARCH_LIST=8.6 variable. I've read that this variable affects only the source installation.

Basically I am following this guide (linux system, using pip instead of conda) but I was not able to understand how to correctly set the CMAKE_PREFIX_PATH variable. Despite this I tried in any case to install pytorch with the python3 setup.py install command but it returned this error:

CMake Error at cmake/public/cuda.cmake:47 (enable_language):
  No CMAKE_CUDA_COMPILER could be found.
  Tell CMake where to find the compiler by setting either the environment
  variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full
  path to the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  cmake/Dependencies.cmake:43 (include)
  CMakeLists.txt:696 (include)

The log file shows this:

Checking whether the CUDA compiler is NVIDIA using "" did not match "nvcc: NVIDIA \(R\) Cuda compiler driver":
Checking whether the CUDA compiler is Clang using "" did not match "(clang version)":
Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: CMAKE_CUDA_COMPILER-NOTFOUND 
Build flags: ;-Xfatbin;-compress-all
Id flags:  -v
The output was:
No such file or directory
Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: CMAKE_CUDA_COMPILER-NOTFOUND 
Build flags: 
Id flags:  -v
The output was:
No such file or directory

Can anybody help me solve this?

Update

Cuda seems to be installed. With apt list --installed|grep cuda this is the output (I am Italian "sconosciuto"=unknown :)

cuda-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-cccl-11-7/sconosciuto,now 11.7.58-1 amd64 [installato, automatico]
cuda-command-line-tools-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-compiler-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-cudart-11-7/sconosciuto,now 11.7.60-1 amd64 [installato, automatico]
cuda-cudart-dev-11-7/sconosciuto,now 11.7.60-1 amd64 [installato, automatico]
cuda-cuobjdump-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-cupti-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-cupti-dev-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-cuxxfilt-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-demo-suite-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-documentation-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-driver-dev-11-7/sconosciuto,now 11.7.60-1 amd64 [installato, automatico]
cuda-drivers-515/sconosciuto,now 515.43.04-1 amd64 [installato, automatico]
cuda-drivers/sconosciuto,now 515.43.04-1 amd64 [installato, automatico]
cuda-gdb-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-libraries-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-libraries-dev-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-memcheck-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nsight-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nsight-compute-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-nsight-systems-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-nvcc-11-7/sconosciuto,now 11.7.64-1 amd64 [installato, automatico]
cuda-nvdisasm-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvml-dev-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvprof-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvprune-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvrtc-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvrtc-dev-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvtx-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-nvvp-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-runtime-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-sanitizer-11-7/sconosciuto,now 11.7.50-1 amd64 [installato, automatico]
cuda-toolkit-11-7-config-common/sconosciuto,now 11.7.60-1 all [installato, automatico]
cuda-toolkit-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-toolkit-11-config-common/sconosciuto,now 11.7.60-1 all [installato, automatico]
cuda-toolkit-config-common/sconosciuto,now 11.7.60-1 all [installato, automatico]
cuda-tools-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda-visual-tools-11-7/sconosciuto,now 11.7.0-1 amd64 [installato, automatico]
cuda/sconosciuto,now 11.7.0-1 amd64 [installato]
libcuda1/sconosciuto,now 515.43.04-1 amd64 [installato, automatico]
nvidia-cuda-mps/sconosciuto,now 515.43.04-1 amd64 [installato, automatico]
                I think i managed to add nvcc to the path (i added /usr/local/cuda-11.7/bin) but nothing changes
– Alessandro Costantini
                May 18, 2022 at 8:33
                1. And what happens if you set the CUDACXX environment variable to ` /usr/local/cuda-11.7/bin/nvcc`? 2. What version of CMake are you using?
– einpoklum
                May 18, 2022 at 10:01
                My cmake version is 3.22.4. If i set the CUDACXX variable the installation seems to start and goes on for a while but then stops here:  "ninja: build stopped: subcommand failed".
– Alessandro Costantini
                May 18, 2022 at 14:21
                Then your question is resolved, albeit not in the cleanest way. Check your ninja log to figure out why your build failed. I suggest you open a bug against pytorch for it failing to identify your CUDA installation.
– einpoklum
                May 18, 2022 at 14:34

My guess is that the CUDA installation is somehow messed up / invisible - otherwise CMake should have noticed it. You can overcome the issue more "manually" by running CMake like so:

CUDACXX=/usr/local/cuda-11.7/bin/nvcc cmake -S /path/to/source/dir -B /path/to/build/dir

(as you have installed CUDA under /usr/local/cuda-11.7)

A less-likely cause is that CMake doesn't properly recognize the just-released CUDA 11.7, although I doubt it.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.