Cuda 12.1 - Error when building cuda samples

I installed Cudatoolkit 12.1 on laptop with Ubuntu 22.04. The GPU is the mobile RTX 3080, CPU is AMD 5900HX. GCC version is 12.2.

The install went fine and it mostly seems to be working fine. I decided to compile all the cuda samples and got this error -

>>> GCC Version is greater or equal to  5.1.0 <<<
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../../Common -m64 --std=c++11 --threads 0 -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 simpleAWBarrier.o -c
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda/std/barrier(144): error: function "operator new" cannot be called with the given argument list
            argument types are: (unsigned long, cuda::std::__4::__barrier_base<cuda::std::__4::__empty_completion, 2> *)
         new (&__b->__barrier) __barrier_base(__expected); 

1 error detected in the compilation of "".
make: *** [Makefile:361: simpleAWBarrier.o] Error 255

The error doesn’t seem to be in the sample program but a standard include from the toolkit.

1 Like

I’m experiencing exact same problem with CUDA 12.1 and gcc version 12.2. The error is indeed in CUDA library headers. However this error is not present if using Nvidia’s CUDA 12.1 container. The difference is the container uses much older version of gcc, I believe version 7. So it seems that newer version of gcc has more stringent error checking, and as far as I can tell this new operator is indeed not legal.

1 Like

I installed gcc/g++ version 9.5.0 and it compiles. I still believe that code in question is invalid but looks like older compiler is less restrictive.

Same problem here… debian 11, all tools up to date… Someone has managed to solve this on newer gcc/g++?

Same problem when compiling with clang 15. This is definitely a bug.

It turns out that samples compile with GCC up to version 11. Coincidentally that is the version packaged with Ubuntu 22.04, which is the highest version officially supported by CUDA.