No CMAKE_CUDA_COMPILER could be found when installing pytorch
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 &quot;CUDACXX&quot; 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 &quot;&quot; did not match &quot;nvcc: NVIDIA \(R\) Cuda compiler driver&quot;:
Checking whether the CUDA compiler is Clang using &quot;&quot; did not match &quot;(clang version)&quot;:
Compiling the CUDA compiler identification source file &quot;CMakeCUDACompilerId.cu&quot; 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 &quot;CMakeCUDACompilerId.cu&quot; 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 &quot;sconosciuto&quot;=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]


My guess is that the CUDA installation is somehow messed up / invisible - otherwise CMake should have noticed it. You can overcome the issue more &quot;manually&quot; 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.
