Nvcc 12.3 with gcc 13.2 not working

After updating to cuda 12.3, the compiler fails to compile most codes. Is there some configuration that I should do, or will I need to roll back the version? Any help is much appreciated.

When using make to compile cuda samples:

make[1]: Entering directory '/data/opt/cuda-samples-12.3/Samples/6_Performance/alignedTypes'
/opt/cuda/bin/nvcc -ccbin g++ -I../../../Common -m64 --threads 0 --std=c++11 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_89,code=sm_89 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o alignedTypes.o -c alignedTypes.cu
/usr/include/bits/floatn.h(86): error: invalid combination of type specifiers
  typedef __float128 _Float128;
                     ^

/usr/include/bits/floatn-common.h(214): error: invalid combination of type specifiers
  typedef float _Float32;
                ^

/usr/include/bits/floatn-common.h(251): error: invalid combination of type specifiers
  typedef double _Float64;
                 ^

/usr/include/bits/floatn-common.h(268): error: invalid combination of type specifiers
  typedef double _Float32x;
                 ^

/usr/include/bits/floatn-common.h(285): error: invalid combination of type specifiers
  typedef long double _Float64x;
                      ^

5 errors detected in the compilation of "alignedTypes.cu".
make[1]: *** [Makefile:328: alignedTypes.o] Error 255
make[1]: Leaving directory '/data/opt/cuda-samples-12.3/Samples/6_Performance/alignedTypes'
make: *** [Makefile:45: Samples/6_Performance/alignedTypes/Makefile.ph_build] Error 2

When using cmake to compile my own code.

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

  Compiler: /opt/cuda/bin/nvcc

  Build flags:

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



  The output was:

  2

  #$ _NVVM_BRANCH_=nvvm

  #$ _SPACE_=

  #$ _CUDART_=cudart

  #$ _HERE_=/opt/cuda/bin

  #$ _THERE_=/opt/cuda/bin

  #$ _TARGET_SIZE_=

  #$ _TARGET_DIR_=

  #$ _TARGET_DIR_=targets/x86_64-linux

  #$ TOP=/opt/cuda/bin/..

  #$ NVVMIR_LIBRARY_DIR=/opt/cuda/bin/../nvvm/libdevice

  #$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:

  #$
  PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cuda/bin:/opt/cuda/nsight_compute:/opt/cuda/nsight_systems/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl


  #$ INCLUDES="-I/opt/cuda/bin/../targets/x86_64-linux/include"

  #$ LIBRARIES= "-L/opt/cuda/bin/../targets/x86_64-linux/lib/stubs"
  "-L/opt/cuda/bin/../targets/x86_64-linux/lib"

  #$ CUDAFE_FLAGS=

  #$ PTXAS_FLAGS=

  #$ rm tmp/a_dlink.reg.c

  #$ gcc -D__CUDA_ARCH_LIST__=520 -E -x c++ -D__CUDACC__ -D__NVCC__
  "-I/opt/cuda/bin/../targets/x86_64-linux/include" -D__CUDACC_VER_MAJOR__=12
  -D__CUDACC_VER_MINOR__=3 -D__CUDACC_VER_BUILD__=52
  -D__CUDA_API_VER_MAJOR__=12 -D__CUDA_API_VER_MINOR__=3
  -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -include "cuda_runtime.h" -m64
  "CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp4.ii"

  #$ cudafe++ --c++17 --gnu_version=130201 --display_error_number
  --orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name
  "/tmp/tmp.7ejqaF2sAk/build/Core/CMakeFiles/3.27.7/CompilerIdCUDA/CMakeCUDACompilerId.cu"
  --allow_managed --m64 --parse_templates --gen_c_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.cpp" --stub_file_name
  "CMakeCUDACompilerId.cudafe1.stub.c" --gen_module_id_file
  --module_id_file_name "tmp/CMakeCUDACompilerId.module_id"
  "tmp/CMakeCUDACompilerId.cpp4.ii"

  /usr/include/bits/floatn.h(86): error: invalid combination of type
  specifiers

    typedef __float128 _Float128;
                       ^

  

  /usr/include/bits/floatn-common.h(214): error: invalid combination of type
  specifiers

    typedef float _Float32;
                  ^

  

  /usr/include/bits/floatn-common.h(251): error: invalid combination of type
  specifiers

    typedef double _Float64;
                   ^

  

  /usr/include/bits/floatn-common.h(268): error: invalid combination of type
  specifiers

    typedef double _Float32x;
                   ^

  

  /usr/include/bits/floatn-common.h(285): error: invalid combination of type
  specifiers

    typedef long double _Float64x;
                        ^

  

  5 errors detected in the compilation of "CMakeCUDACompilerId.cu".

  # --error 0x2 --





Call Stack (most recent call first):
  /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
  /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
  /usr/share/cmake/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
  CMakeLists.txt:2 (project)


CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
make: Makefile: No such file or directory
make: *** No rule to make target 'Makefile'.  Stop.
Core build failed
cppsrc build failed
3 Likes

Same thing is happening to me trying to install a Python package with a C++ component. I was told in a Github issue to make sure that CUDA supported my version of GCC, but was hoping for a fix without having to roll one of them back.

The supported/tested gcc versions for any given CUDA version can be found in the CUDA linux install guide for that CUDA version. At the moment, here (and here) is the one for 12.3, and you can see that gcc 13.x is not listed anywhere.

So there is no expectation by NVIDIA that CUDA 12.3 works with gcc 13.x. For CUDA 12.3, the stated gcc support goes up to gcc 12.2.

the same issue here,

gcc --version
gcc (GCC) 13.2.1 20230801

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Sep__8_19:17:24_PDT_2023
Cuda compilation tools, release 12.3, V12.3.52
Build cuda_12.3.r12.3/compiler.33281558_0
/opt/cuda/bin/nvcc -ccbin g++ -DDUFFING_MODEL -DLYAPUNOV_METRICS -Iinclude/ -dc --threads 0 --std=c++11 -lcuda -o tests_lyapunov.o -c tests/tests_lyapunov.cu
/usr/include/bits/floatn.h(86): error: invalid combination of type specifiers
  typedef __float128 _Float128;
                     ^

/usr/include/bits/floatn-common.h(214): error: invalid combination of type specifiers
  typedef float _Float32;
                ^

/usr/include/bits/floatn-common.h(251): error: invalid combination of type specifiers
  typedef double _Float64;
                 ^

/usr/include/bits/floatn-common.h(268): error: invalid combination of type specifiers
  typedef double _Float32x;
                 ^

/usr/include/bits/floatn-common.h(285): error: invalid combination of type specifiers
  typedef long double _Float64x;
                      ^

5 errors detected in the compilation of "tests/tests_lyapunov.cu".
make: *** [Makefile:92: tests_lyapunov.o] Error 255

I believe this may be an nvcc issue. Currently, on arch linux gcc 13 is the default gcc version. However, cuda uses (should use?) gcc 12, and indeed, gcc 12 is a dependency of the cuda package and it is correctly installed.

Unfortunately, nvcc is mixing gcc 12 and 13, and this seems to cause the issue.

For example, as of today:

$ cat test.cu
#include <stdio.h>

int main() { }
$ nvcc test.cu
/usr/include/bits/floatn.h(86): error: invalid combination of type specifiers
  typedef __float128 _Float128;
                     ^

/usr/include/bits/floatn-common.h(214): error: invalid combination of type specifiers
  typedef float _Float32;
                ^

/usr/include/bits/floatn-common.h(251): error: invalid combination of type specifiers
  typedef double _Float64;
                 ^

/usr/include/bits/floatn-common.h(268): error: invalid combination of type specifiers
  typedef double _Float32x;
                 ^

/usr/include/bits/floatn-common.h(285): error: invalid combination of type specifiers
  typedef long double _Float64x;
                      ^

5 errors detected in the compilation of "test.cu".

Even though the headers (which are glibc headers) have the necessary guards, e.g.:

#  if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0))
typedef float _Float32;
#  endif

they are defeated by nvcc mixing gcc 12 and 13.

$ strace -e execve -s 9999 -f nvcc test.cu
[...]
[pid 189798] execve("/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/cc1plus", ["/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/cc1plus", "-E", "-quiet", "-D_GNU_SOURCE", "/tmp/tmpxft_0002e564_00000000-2.cpp", "-mtune=generic", "-march=x86-64", "-dumpbase", "tmpxft_0002e564_00000000-2.cpp", "-dumpbase-ext", ".cpp"], 0x1cc0d80 /* 64 vars */) = 0
[...]
[pid 189800] execve("/usr/lib/gcc/x86_64-pc-linux-gnu/12.3.0/cc1plus", ["/usr/lib/gcc/x86_64-pc-linux-gnu/12.3.0/cc1plus", "-E", "-quiet", "-I", "/opt/cuda/bin/../targets/x86_64-linux/include", "-D_GNU_SOURCE", "-D", "__CUDA_ARCH_LIST__=520", "-D", "__CUDACC__", "-D", "__NVCC__", "-D", "__CUDACC_VER_MAJOR__=12", "-D", "__CUDACC_VER_MINOR__=3", "-D", "__CUDACC_VER_BUILD__=52", "-D", "__CUDA_API_VER_MAJOR__=12", "-D", "__CUDA_API_VER_MINOR__=3", "-D", "__NVCC_DIAG_PRAGMA_SUPPORT__=1", "-include", "cuda_runtime.h", "test.cu", "-o", "/tmp/tmpxft_0002e564_00000000-5_test.cpp4.ii", "-m64", "-mtune=generic", "-march=x86-64", "-dumpdir", "/tmp/", "-dumpbase", "tmpxft_0002e564_00000000-5_test.cpp4.cu", "-dumpbase-ext", ".cu"], 0x21cd730 /* 77 vars */) = 0
[...]
[pid 189801] execve("/opt/cuda/bin/cudafe++", ["cudafe++", "--c++17", "--gnu_version=130201", "--display_error_number", "--orig_src_file_name", "test.cu", "--orig_src_path_name", "/tmp/test.cu", "--allow_managed", "--m64", "--parse_templates", "--gen_c_file_name", "/tmp/tmpxft_0002e564_00000000-6_test.cudafe1.cpp", "--stub_file_name", "tmpxft_0002e564_00000000-6_test.cudafe1.stub.c", "--gen_module_id_file", "--module_id_file_name", "/tmp/tmpxft_0002e564_00000000-4_test.module_id", "/tmp/tmpxft_0002e564_00000000-5_test.cpp4.ii"], 0x555e63c36340 /* 75 vars */) = 0

Note that gcc 13 is used first, then gcc 12, then cudafe++ is executed with --gnu_version=130201, which ultimately fails with the above error messages.

Specifying -ccbin=/opt/cuda/bin (which has the gcc and g++ symbolic links to the gcc 12 versions) fixes the issue, and gcc 12 will be used all the way (and --gnu_version=120300 will be specified when executing cudafe++). (If you use meson, you can set -D cuda_ccbindir=/opt/cuda/bin.)

EDIT: It looks like I’m way too late. Based on the following comment, this has already been reported to nvidia: cuda.sh · 4e66a3ddd593027aaadbf731b6c56de154292344 · Arch Linux / Packaging / Packages / cuda · GitLab