instant-ngp icon indicating copy to clipboard operation
instant-ngp copied to clipboard

Compilation error ptxas fatal : Value 'sm_30' is not defined for option 'gpu-name'

Open happysxpp opened this issue 2 years ago • 11 comments

I'm receiving the following build error on Ubuntu 22.04.

instant-ngp$ cmake . -B build

CMake Error at /usr/local/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:739 (message):
  Compiling the CUDA compiler identification source file
  "CMakeCUDACompilerId.cu" failed.

  Compiler: /usr/bin/nvcc

  Build flags:

  Id flags: --keep;--keep-dir;tmp -v

  The output was:

  255
  #$ _SPACE_=
  #$ _CUDART_=cudart
  #$ _HERE_=/usr/lib/nvidia-cuda-toolkit/bin
  #$ _THERE_=/usr/lib/nvidia-cuda-toolkit/bin
  #$ _TARGET_SIZE_=
  #$ _TARGET_DIR_=
  #$ _TARGET_SIZE_=64
  #$ NVVMIR_LIBRARY_DIR=/usr/lib/nvidia-cuda-toolkit/libdevice
  #$
  PATH=/usr/lib/nvidia-cuda-toolkit/bin:/usr/local/cuda-11.3/bin:/home/zzc/miniconda3/bin:/home/zzc/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

  #$ LIBRARIES= -L/usr/lib/x86_64-linux-gnu/stubs -L/usr/lib/x86_64-linux-gnu

  #$ rm tmp/a_dlink.reg.c

  #$ gcc -D__CUDA_ARCH__=300 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS
  -D__CUDACC__ -D__NVCC__ -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1
  -D__CUDACC_VER_BUILD__=243 -include "cuda_runtime.h" -m64
  "CMakeCUDACompilerId.cu" > "tmp/CMakeCUDACompilerId.cpp1.ii"

  #$ cicc --c++14 --gnu_version=90400 --allow_managed -arch compute_30 -m64
  -ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 --include_file_name
  "CMakeCUDACompilerId.fatbin.c" -tused -nvvmir-library
  "/usr/lib/nvidia-cuda-toolkit/libdevice/libdevice.10.bc"
  --gen_module_id_file --module_id_file_name
  "tmp/CMakeCUDACompilerId.module_id" --orig_src_file_name
  "CMakeCUDACompilerId.cu" --gen_c_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.c" --stub_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.stub.c" --gen_device_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.gpu" "tmp/CMakeCUDACompilerId.cpp1.ii" -o
  "tmp/CMakeCUDACompilerId.ptx"

  #$ ptxas -arch=sm_30 -m64 "tmp/CMakeCUDACompilerId.ptx" -o
  "tmp/CMakeCUDACompilerId.sm_30.cubin"

  ptxas fatal : Value 'sm_30' is not defined for option 'gpu-name'

  # --error 0xff --

Call Stack (most recent call first):
  /usr/local/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  /usr/local/share/cmake-3.24/Modules/CMakeDetermineCompilerId.cmake:48 (__determine_compiler_id_test)
  /usr/local/share/cmake-3.24/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:11 (project)

-- Configuring incomplete, errors occurred!
nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0

Is there any way to fix this ?

happysxpp avatar Jul 06 '22 10:07 happysxpp

I am facing the same issue as well! Any pointers on how to resolve this issue?

viraj96 avatar Aug 13 '22 17:08 viraj96

Downgrading nvcc to 10.2 solved it for me.

viraj96 avatar Aug 13 '22 17:08 viraj96

I also have the same issue using cuda 11.4 & 11.7

iahmedmaher avatar Aug 15 '22 22:08 iahmedmaher

Based on the line: -D__CUDACC__ -D__NVCC__ -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1

It seems like it's detecting a cuda compiler version of 10.1. My usual CUDA install is done via the normal .run method, installed in /usr/local/cuda...., so nvcc --version should correspond to that version.

You might have an old installation of nvidia-cuda-toolkit installed via apt-get (like me). To check, run: apt-cache policy nvidia-cuda-toolkit

I suspect you have that package installed and the version is 10.1, so you'll want to remove it.

sudo apt remove nvidia-cuda-toolkit

neil454 avatar Sep 19 '22 23:09 neil454

You might have an old installation of nvidia-cuda-toolkit installed via apt-get (like me). To check, run: apt-cache policy nvidia-cuda-toolkit

I suspect you have that package installed and the version is 10.1, so you'll want to remove it.

sudo apt remove nvidia-cuda-toolkit

This solved it for me

dennisushi avatar Jan 09 '23 17:01 dennisushi

Hi, for me after I run sudo apt remove nvidia-cuda-toolkit and try to build I receive the error:

CMake Error at CMakeLists.txt:11 (project):
  The CMAKE_CUDA_COMPILER:

    /usr/bin/nvcc

  is not a full path to an existing compiler tool.

  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.

Reinstalling sudo apt-get install nvidia-cuda-toolkit leads to the original error in this issue, and my nvidia-cuda-toolkit still seems to be outdated; apt-cache policy nvidia-cuda-toolkit throws:

nvidia-cuda-toolkit:
  Installed: 10.1.243-3
  Candidate: 10.1.243-3

Don't understand why this would happen considering nvidia-smi says CUDA Version: 12.0. Also nvcc -V -> Build cuda_12.0.r12.0/compiler.32267302_0

After uninstalling nvidia-cuda-toolkit again, I tried to follow: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_local but in the end this just outputted cuda is already the newest version (12.0.1-1).

Any ideas?

Zador-Pataki avatar Feb 07 '23 17:02 Zador-Pataki

@Zador-Pataki deleting the build folder after sudo apt remove nvidia-cuda-toolkit solved it for me

nepfaff avatar Mar 24 '23 17:03 nepfaff

I add this content in my CMakeLists.txt and it can work. OS: Ubuntu20.04(WSL) NVCC-V: 11.4

     set(CMAKE_CUDA_ARCHITECTURES 70 75 80)
     set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
     set(CUDACXX /usr/local/cuda/bin/nvcc)

xioaxin avatar Dec 10 '23 06:12 xioaxin

Based on the line: -D__CUDACC__ -D__NVCC__ -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1

It seems like it's detecting a cuda compiler version of 10.1. My usual CUDA install is done via the normal .run method, installed in /usr/local/cuda...., so nvcc --version should correspond to that version.

You might have an old installation of nvidia-cuda-toolkit installed via apt-get (like me). To check, run: apt-cache policy nvidia-cuda-toolkit

I suspect you have that package installed and the version is 10.1, so you'll want to remove it.

sudo apt remove nvidia-cuda-toolkit

This worked. I had manually installed cuda-12.1 from the nvidia website. However, the package "nvidia-cuda-toolkit" still makes it point to 10.1.

atmadeep avatar Feb 28 '24 11:02 atmadeep

same issue competently unrelated to the project (just trying to compile the most basic openmp on gpu) my nvcc is 12.3 and I am trying it with gcc11 gcc12 and nvcc mothing

nevakrien avatar Mar 10 '24 16:03 nevakrien