Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
happysxpp opened this issue Jul 6, 2022 · 13 comments

Comments

@happysxpp
Copy link

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 ?

@virajparimi
Copy link

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

@virajparimi
Copy link

Downgrading nvcc to 10.2 solved it for me.

@iahmedmaher
Copy link

I also have the same issue using cuda 11.4 & 11.7

@neil454
Copy link

neil454 commented Sep 19, 2022

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

@dennisushi
Copy link

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

@Zador-Pataki
Copy link

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?

@nepfaff
Copy link

nepfaff commented Mar 24, 2023

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

@xioaxin
Copy link

xioaxin commented Dec 10, 2023

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)

@atmadeep
Copy link

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.

@nevakrien
Copy link

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

@yuqilol
Copy link

yuqilol commented Jun 18, 2024

根据以下行: -D__CUDACC__ -D__NVCC__ -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1

似乎检测到了 10.1 版的 cuda 编译器。我通常通过常规 .run 方法安装 CUDA,安装在 /usr/local/cuda.... 中,因此nvcc --version应该与该版本相对应。

您可能已经通过 apt-get 安装了旧的 nvidia-cuda-toolkit(像我一样)。要检查,请运行: apt-cache policy nvidia-cuda-toolkit

我怀疑您已经安装了该软件包并且版本是 10.1,因此您需要将其删除。

sudo apt remove nvidia-cuda-toolkit

31/5000
I think the problem is not referencing cuda rather than not downloading the correct cuda
use which nvcc find cuda's location
in cmakelists.txt top insert
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc) # Replace with your nvcc path

@chreyson
Copy link

you can add these into CMakeLists.txt to solve this:
set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")
set(CMAKE_CUDA_ARCHITECTURES 52 60 61 75 86)

@ldtanh
Copy link

ldtanh commented Feb 11, 2025

you can add these into CMakeLists.txt to solve this: set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc") set(CMAKE_CUDA_ARCHITECTURES 52 60 61 75 86)

This is much more reasonable for me and worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests