error: exception specification is incompatible with that of previous function "cospi"
OS: Ubuntu 25.04 Cuda version: 12.9
After installing the Nvidia driver and CUDA driver, I always run the cuda-samples to test that it is working as expected. It has worked previously but last time I installed it, the samples cannot be compiled as they run into this issue:
usr/include/x86_64-linux-gnu/bits/mathcalls.h(79): error: exception
specification is incompatible with that of previous function "cospi"
(declared at line 2601 of
/usr/local/cuda-12.9/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern double cospi (double __x) noexcept (true); extern double __cospi (double __x) noexcept (true);
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h(81): error: exception
specification is incompatible with that of previous function "sinpi"
(declared at line 2556 of
/usr/local/cuda-12.9/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern double sinpi (double __x) noexcept (true); extern double __sinpi (double __x) noexcept (true);
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h(79): error: exception
specification is incompatible with that of previous function "cospif"
(declared at line 2623 of
/usr/local/cuda-12.9/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern float cospif (float __x) noexcept (true); extern float __cospif (float __x) noexcept (true);
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h(81): error: exception
specification is incompatible with that of previous function "sinpif"
(declared at line 2579 of
/usr/local/cuda-12.9/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern float sinpif (float __x) noexcept (true); extern float __sinpif (float __x) noexcept (true);
This forum post show there are several people that have this issue across other CUDA versions and Distro's. The workaround is included in this post but this has been an issue for several months now, is there an offical solution planned for this? Running CUDA compilations through Nvidias docker image works as well.
@vluni-g did you find any fix? I'm also on same ubuntu & cuda version facing exact same error
@ashar340 both ways are included in the post but https://forums.developer.nvidia.com/t/error-exception-specification-is-incompatible-for-cospi-sinpi-cospif-sinpif-with-glibc-2-41/323591 works for host installed conda environment, https://hub.docker.com/r/nvidia/cuda works if you don't want to mess around with files as the previous link
I get a similar issue on ubuntu 25.10, albeit with different functions:
/usr/local/cuda-13.0/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern double rsqrt (double __x) noexcept (true); extern double __rsqrt (double __x) noexcept (true);
^
/usr/include/x86_64-linux-gnu/bits/mathcalls.h(206): error: exception
specification is incompatible with that of previous function "rsqrtf"
(declared at line 653 of
/usr/local/cuda-13.0/bin/../targets/x86_64-linux/include/crt/math_functions.h)
extern float rsqrtf (float __x) noexcept (true); extern float __rsqrtf (float __x) noexcept (true);
the workaround from the OP to edit the headers seems to have moved things forward for now