Full error output: cuda-glibc-2.41-cmake-errors.txt · GitHub
These trigonometric functions are new additions to Glibc’s math headers: https://www.phoronix.com/news/Glibc-2.41-More-C23
Full error output: cuda-glibc-2.41-cmake-errors.txt · GitHub
These trigonometric functions are new additions to Glibc’s math headers: https://www.phoronix.com/news/Glibc-2.41-More-C23
glibc 2.41 is not supported for any version of CUDA at the moment. (e.g. CUDA 12.8)
For the record, this naive patch fixes my problem on Gentoo ~amd64 (where downgrading glibc is not possible):
diff '--color=auto' -ur builds.orig/cuda_nvcc/targets/x86_64-linux/include/crt/math_functions.h builds/cuda_nvcc/targets/x86_64-linux/include/crt/math_functions.h
--- a/builds.orig/cuda_nvcc/targets/x86_64-linux/include/crt/math_functions.h 2024-08-23 00:25:39.000000000 +0200
+++ b/builds/cuda_nvcc/targets/x86_64-linux/include/crt/math_functions.h 2025-02-17 01:19:44.270292640 +0100
@@ -2547,7 +2547,7 @@
*
* \note_accuracy_double
*/
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x) noexcept (true);
/**
* \ingroup CUDA_MATH_SINGLE
* \brief Calculate the sine of the input argument
@@ -2570,7 +2570,7 @@
*
* \note_accuracy_single
*/
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x) noexcept (true);
/**
* \ingroup CUDA_MATH_DOUBLE
* \brief Calculate the cosine of the input argument
@@ -2592,7 +2592,7 @@
*
* \note_accuracy_double
*/
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x) noexcept (true);
/**
* \ingroup CUDA_MATH_SINGLE
* \brief Calculate the cosine of the input argument
@@ -2614,7 +2614,7 @@
*
* \note_accuracy_single
*/
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x) noexcept (true);
/**
* \ingroup CUDA_MATH_DOUBLE
* \brief Calculate the sine and cosine of the first input argument
Tested with both CUDA 12.6.1 and 12.8.0 .
The patch from stefan works for me. Looks like CUDAs headers have a literal bug, where the extern
definition doesn’t match the actual function definition. His patch just makes them match. NVIDIA should probably make this change official in every architecture variant of math_functions.h.
Hello,
I confirm the problem with Ubuntu 25.04! The compilation of my program fails as soon as the cmake. After modifying /usr/local/cuda-12.8/targets/x86_64-linux/include/crt/math_functions.h everything works again!
I found this post right after after asking the same question on StackOverflow (and right after hitting the same problem on my machine). I adapted the patch slightly - changing the a/
and b/
parts not to assume the same directory structure. Also gave you credit.
I work with Fedora 42, clang 18.1.8, CUDA 12.8. For me, I needed to add some noexcepts to math_functions.hpp as well for CUDA compilation to work.
This worked for me too on Fedora 42 , nvcc version Build cuda_12.9.r12.9/compiler.35813241_0
The workarounds involved
Installing the Fedora 41 version of the CUDA toolkit (this mostly worked)
Install the gcc14 “sudo dnf5 install gcc14 gcc14-c++”
Edit the file
/usr/local/cuda-12.9/targets/x86_64-linux/include/crt/math_functions.h as described in the patch, which is essentially adding “noexcept (true)” for those specific files
Set “export NVCC_CCBIN=/usr/bin/g+±14” before running cmake
Hope this helps