Building from source: nvcc fatal : Unsupported gpu architecture 'compute_120'

paat: <p>Hey! I am bit obsessed/frustrated with trying to have successful PyTorch build. Stuck with TensorFactories.cu giving <code>Unsupported gpu architecture ‘compute_120’</code> error.</p>
<p>Can anybody help me?</p>
<h3><a name="p-474092-env-1" class="anchor" href="#p-474092-env-1"></a>Env</h3>
<pre><code class="lang-auto">GPU RTX 5090
CPU Threadripper PRO 7965WX

OS: Ubuntu 24.04.2 LTS
Kernel: 6.14.0-27-generic
Driver: 575.64.03
CUDA Version: 12.9
NVCC V12.9.86
GCC 12.3.0
Python 3.12.3
</code></pre>
<h3><a name="p-474092-build-steps-2" class="anchor" href="#p-474092-build-steps-2"></a>Build steps</h3>
<h4><a name="p-474092-update-source-code-3" class="anchor" href="#p-474092-update-source-code-3"></a>Update source code</h4>
<pre><code class="lang-auto">git pull origin main
git submodule sync --recursive
git submodule update --init --recursive
</code></pre>
<h4><a name="p-474092-install-python-dependencies-4" class="anchor" href="#p-474092-install-python-dependencies-4"></a>Install python dependencies</h4>
<pre><code class="lang-auto">pip install -r requirements.txt
</code></pre>
<h4><a name="p-474092-set-env-variables-5" class="anchor" href="#p-474092-set-env-variables-5"></a>Set env variables</h4>
<pre><code class="lang-auto">export USE_CUDA=1
export TORCH_CUDA_ARCH_LIST="12.0"
export BLAS=BLIS
export BLIS_HOME=/opt/AMD/aocl/aocl-linux-gcc-5.1.0/gcc
export USE_MKL=0
export USE_MKLDNN=0
export USE_FLASH_ATTENTION=0
export BUILD_TEST=0
export USE_GLOO=0
export USE_DISTRIBUTED=0
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which python))/../"}
</code></pre>
<h4><a name="p-474092-build-6" class="anchor" href="#p-474092-build-6"></a>Build</h4>
<pre><code class="lang-auto">python setup.py clean
python setup.py develop
</code></pre>
<h3><a name="p-474092-error-7" class="anchor" href="#p-474092-error-7"></a>Error</h3>
<pre><code class="lang-auto">[4232/6662] Building CUDA object caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/TensorFactories.cu.o
FAILED: [code=1] caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/TensorFactories.cu.o
/usr/bin/nvcc -forward-unknown-to-host-compiler -DAT_PER_OPERATOR_HEADERS -DCPUINFO_SUPPORTED_PLATFORM=1 -DFBGEMM_STATIC -DFMT_HEADER_ONLY=1 -DFXDIV_USE_INLINE_ASSEMBLY=0 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DNNP_CONVOLUTION_ONLY=0 -DNNP_INFERENCE_ONLY=0 -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTORCH_CUDA_BUILD_MAIN_LIB -DTORCH_CUDA_USE_NVTX3 -DUSE_CUDA -DUSE_CUFILE -DUSE_EXTERNAL_MZCRC -DUSE_MEM_EFF_ATTENTION -DXNN_LOG_LEVEL=0 -D_FILE_OFFSET_BITS=64 -I/mnt/data/ai/pytorch/build/aten/src -I/mnt/data/ai/pytorch/aten/src -I/mnt/data/ai/pytorch/build -I/mnt/data/ai/pytorch -I/mnt/data/ai/pytorch/nlohmann -I/mnt/data/ai/pytorch/moodycamel -I/mnt/data/ai/pytorch/aten/src/THC -I/mnt/data/ai/pytorch/aten/src/ATen/cuda -I/mnt/data/ai/pytorch/third_party/fmt/include -I/mnt/data/ai/pytorch/aten/src/ATen/../../../third_party/cutlass/include -I/mnt/data/ai/pytorch/aten/src/ATen/../../../third_party/cutlass/tools/util/include -I/mnt/data/ai/pytorch/build/caffe2/aten/src -I/mnt/data/ai/pytorch/aten/src/ATen/.. -I/mnt/data/ai/pytorch/c10/cuda/../.. -I/mnt/data/ai/pytorch/c10/.. -I/mnt/data/ai/pytorch/torch/csrc/api -I/mnt/data/ai/pytorch/torch/csrc/api/include -I/mnt/data/ai/pytorch/third_party/FXdiv/include -I/mnt/data/ai/pytorch/third_party/pthreadpool/include -I/mnt/data/ai/pytorch/third_party/cpuinfo/include -I/mnt/data/ai/pytorch/aten/src/ATen/native/quantized/cpu/qnnpack/include -I/mnt/data/ai/pytorch/aten/src/ATen/native/quantized/cpu/qnnpack/src -I/mnt/data/ai/pytorch/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/include -I/mnt/data/ai/pytorch/third_party/NNPACK/include -I/mnt/data/ai/pytorch/third_party/fbgemm -I/mnt/data/ai/pytorch/third_party/fbgemm/include -I/mnt/data/ai/pytorch/third_party/fbgemm/bench -I/mnt/data/ai/pytorch/third_party/fbgemm/external/asmjit/src -I/mnt/data/ai/pytorch/third_party/FP16/include -I/mnt/data/ai/pytorch/third_party/onnx -I/mnt/data/ai/pytorch/build/third_party/onnx -I/mnt/data/ai/pytorch/third_party/flatbuffers/include -isystem /mnt/data/ai/pytorch/third_party/protobuf/src -isystem /mnt/data/ai/pytorch/third_party/XNNPACK/include -isystem /mnt/data/ai/pytorch/third_party/ittapi/include -isystem /mnt/data/ai/pytorch/cmake/../third_party/eigen -isystem /usr/local/cuda-12.9/include -isystem /mnt/data/ai/pytorch/INTERFACE -isystem /mnt/data/ai/pytorch/third_party/nlohmann/include -isystem /mnt/data/ai/pytorch/third_party/concurrentqueue -isystem /mnt/data/ai/pytorch/third_party/NVTX/c/include -isystem /mnt/data/ai/pytorch/cmake/../third_party/cudnn_frontend/include -DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS -Xfatbin -compress-all -DONNX_NAMESPACE=onnx_torch -gencode arch=compute_120,code=sm_120 -Xcudafe --diag_suppress=cc_clobber_ignored,--diag_suppress=field_without_dll_interface,--diag_suppress=base_class_has_different_dll_interface,--diag_suppress=dll_interface_conflict_none_assumed,--diag_suppress=dll_interface_conflict_dllexport_assumed,--diag_suppress=bad_friend_decl --expt-relaxed-constexpr --expt-extended-lambda  -Wno-deprecated-gpu-targets --expt-extended-lambda -DCUB_WRAPPED_NAMESPACE=at_cuda_detail -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -DC10_NODEPRECATED -O3 -DNDEBUG -std=c++17 -Xcompiler=-fPIC -Xcompiler -Wall -Wextra -Wdeprecated -Wunused -Wno-unused-parameter -Wno-missing-field-initializers -Wno-array-bounds -Wno-unknown-pragmas -Wno-strict-overflow -Wno-strict-aliasing -Wredundant-move -Wno-maybe-uninitialized -pthread -DASMJIT_STATIC -MD -MT caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/TensorFactories.cu.o -MF caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/TensorFactories.cu.o.d -x cu -c /mnt/data/ai/pytorch/aten/src/ATen/native/cuda/TensorFactories.cu -o caffe2/CMakeFiles/torch_cuda.dir/__/aten/src/ATen/native/cuda/TensorFactories.cu.o
nvcc fatal   : Unsupported gpu architecture 'compute_120'
[4281/6662] Building CXX object caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/FlashAttentionKernel.cpp.AVX512.cpp.o
ninja: build stopped: subcommand failed.
</code></pre>

ptrblck: <p>It seems your build process might use an older <code>nvcc</code> which does not support <code>sm_120</code> since CUDA 12.9.x does support it as seen in <a href="https://pytorch.org/get-started/locally/">our builds</a>. I’m not familiar with your use case but you could simply download a stable or nightly binary built with CUDA 12.9 from the linked install matrix as it supports <code>sm_120</code> as well.</p>

paat: <p>Thanks! indeed I had old cuda tools installation interfering with the build. Now I got working. I want to have builds optimized for my system nothing more <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=14" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>