Fedora 43 and NVCC / Cuda13.1 error "exception specification is incompatible" rsqrt / rsqrtf

If you are facing errors like the following when trying to complie applications with NVCC / CUDA 13.1 on Fedora 43


/usr/include/bits/mathcalls.h(206): error: exception specification is
  incompatible with that of previous function "rsqrt" (declared at line 629
  of
  /usr/local/cuda/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/bits/mathcalls.h(206): error: exception specification is
  incompatible with that of previous function "rsqrtf" (declared at line 653
  of
  /usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h)
    extern float rsqrtf (float __x) noexcept (true); extern float __rsqrtf (float __x) noexcept (true);
                                    ^

Its likely due to the fact that glibc’s <math.h> declares rsqrt with noexcept(true), but CUDA’s headers declare it without noexcept (or with a different exception specification).

GCC 14 + glibc are now providing rsqrt/rsqrtf in the standard math library, and there’s a conflict with CUDA’s declarations.

The simplest path is to modify the CUDA headers for math_functions.h to match the glibc math.h headers. The following worked for me

sudo patch -b /usr/local/cuda/targets/x86_64-linux/include/crt/math_functions.h << 'EOF'
--- a/math_functions.h
+++ b/math_functions.h
@@ -626,7 +626,7 @@
  *
  * \note_accuracy_double
  */
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x) noexcept (true);
 
 /**
  * \ingroup CUDA_MATH_SINGLE
@@ -650,7 +650,7 @@
  *
  * \note_accuracy_single
  */
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x) noexcept (true);
 
 #if defined(__QNX__) && !defined(_LIBCPP_VERSION)
 namespace std {
EOF

Hope its helpful for others

thank you very much for sharing,it is useful and helpful!

Note that this only works with gcc, with clang the patch fails to compile.

Hi there. Similar issue, similar solution: opened vim and commented lines mentioned in my error (they were slightly different). Thanks!

btw, this incompatibility seems to be happening due to the fact that CUDA 13 does not yet officially support GCC15. So I compiled it with GCC13:

cmake -B build -DGGML_CUDA=ON -DCMAKE_CUDA_HOST_COMPILER=/usr/bin/g++-13

Newer toolkit versions (I think since 13) now have a special macro called __NV_IEC_60559_FUNCS_EXCEPTION_SPECIFIER to deal with this. You can try if maybe it works on clang with the following patch:

--- math_functions.h.orig	2026-03-07 12:36:19.092019479 +0100
+++ math_functions.h	2026-03-07 17:15:33.322027903 +0100
@@ -604,6 +604,11 @@ extern __DEVICE_FUNCTIONS_DECL__ __devic
 #if defined(__QNX__) && !defined(_LIBCPP_VERSION)
 } /* std */
 #endif
+#if __NV_GLIBC_PROVIDES_IEC_60559_FUNCS
+#define __NV_IEC_60559_FUNCS_EXCEPTION_SPECIFIER __THROW
+#else
+#define __NV_IEC_60559_FUNCS_EXCEPTION_SPECIFIER
+#endif
 /**
  * \ingroup CUDA_MATH_DOUBLE
  * \brief Calculate the reciprocal of the square root of the input argument.
@@ -626,7 +631,7 @@ extern __DEVICE_FUNCTIONS_DECL__ __devic
  *
  * \note_accuracy_double
  */
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x) __NV_IEC_60559_FUNCS_EXCEPTION_SPECIFIER;
 
 /**
  * \ingroup CUDA_MATH_SINGLE
@@ -650,7 +655,8 @@ extern __DEVICE_FUNCTIONS_DECL__ __devic
  *
  * \note_accuracy_single
  */
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x) __NV_IEC_60559_FUNCS_EXCEPTION_SPECIFIER;
+#undef __NV_IEC_60559_FUNCS_EXCEPTION_SPECIFIER
 
 #if defined(__QNX__) && !defined(_LIBCPP_VERSION)
 namespace std {

This is the same mechanism that is now in use for sinpi / cospi and their float variants that used to cause similar problems.

at least on Debian, this has been just fixed in CUDA-13.2

I was running F42+Cuda13.1 when I noticed 13.2 was out and was supported under F43. This is good news as F42 will be out of support in a few weeks time, so I thought I should get the upgrade done. Can’t comment on your specific issue but at least the upgrade was entirely smooth for me, except for adding the 13.2 repo, so I thought it might be useful to others to reply.

I ran:

sudo dnf upgrade --refresh

sudo dnf system-upgrade download --releasever=43

sudo dnf5 offline reboot

(as I was running f42 at this point)

When it came back F43 seemed ok.

However when I went to add the cuda 13.2 repo via the Cuda installation Guide method:

sudo dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/fedora43/x86_64/cuda-fedora43.repo

it failed.

it appears the dnf command line options have changed, I had to do:

sudo dnf config-manager addrepo --from-repofile=https://developer.download.nvidia.com/compute/cuda/repos/fedora43/x86_64/cuda-fedora43.repo

I ran:

sudo dnf upgrade --refresh  

That upgraded the driver and cuda installation without complaint.

Then disabled the 13.1 repo in gnome software.

reboot.

As far as I can tell all seems well (obviously I have done a great amount of testing in 1 day!)

Best of luck.

Fixed, thanks. It will be online soon. It was still using the Fedora 40 syntax (DNF 4).

Glad to help.

BTW I have not tried:

dnf config-manager add-repo --from-repofile=

from the revised installation guide, but I have only seen (in dnf help) and used:

dnf config-manager addrepo --from-repofile=

add-repo might work as a synonym but thought I would mention it, just in case it doesn’t…..

Thanks, working on Ubuntu as well