Error compiling gromacs 2025.0 with CUDA

GROMACS version: 2025.0
GROMACS modification: No
Here post your question

I’m trying to compile GROMACS 2025.0 with GPU support (cuda) with nvcc version 12.8, and I get the following after running " cmake … -DGMX_GPU=CUDA":

-- The C compiler identification is GNU 14.2.1
-- The CXX compiler identification is GNU 14.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python3: /usr/bin/python3.13 (found suitable version "3.13.1", minimum required is "3.9") found components: Interpreter Development Development.Module Development.Embed
-- Selected GPU FFT library - cuFFT
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Performing Test CFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS
-- Performing Test CFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS - Success
-- Performing Test CFLAGS_EXCESS_PREC
-- Performing Test CFLAGS_EXCESS_PREC - Success
-- Performing Test CFLAGS_COPT
-- Performing Test CFLAGS_COPT - Success
-- Performing Test CFLAGS_NOINLINE
-- Performing Test CFLAGS_NOINLINE - Success
-- Performing Test CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS
-- Performing Test CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS - Success
-- Performing Test CXXFLAGS_EXCESS_PREC
-- Performing Test CXXFLAGS_EXCESS_PREC - Success
-- Performing Test CXXFLAGS_COPT
-- Performing Test CXXFLAGS_COPT - Success
-- Performing Test CXXFLAGS_NOINLINE
-- Performing Test CXXFLAGS_NOINLINE - Success
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for include file pwd.h
-- Looking for include file pwd.h - found
-- Looking for include file dirent.h
-- Looking for include file dirent.h - found
-- Looking for include file time.h
-- Looking for include file time.h - found
-- Looking for include file sys/time.h
-- Looking for include file sys/time.h - found
-- Looking for include file io.h
-- Looking for include file io.h - not found
-- Looking for include file sched.h
-- Looking for include file sched.h - found
-- Looking for include file xmmintrin.h
-- Looking for include file xmmintrin.h - found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for nice
-- Looking for nice - found
-- Looking for fsync
-- Looking for fsync - found
-- Looking for _fileno
-- Looking for _fileno - not found
-- Looking for fileno
-- Looking for fileno - found
-- Looking for _commit
-- Looking for _commit - not found
-- Looking for sigaction
-- Looking for sigaction - found
-- Performing Test HAVE_BUILTIN_CLZ
-- Performing Test HAVE_BUILTIN_CLZ - Success
-- Performing Test HAVE_BUILTIN_CLZLL
-- Performing Test HAVE_BUILTIN_CLZLL - Success
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for feenableexcept in m
-- Looking for feenableexcept in m - found
-- Looking for fedisableexcept in m
-- Looking for fedisableexcept in m - found
-- Checking for sched.h GNU affinity API
-- Performing Test sched_affinity_compile
-- Performing Test sched_affinity_compile - Success
-- Looking for include file mm_malloc.h
-- Looking for include file mm_malloc.h - found
-- Looking for include file malloc.h
-- Looking for include file malloc.h - found
-- Checking for _mm_malloc()
-- Checking for _mm_malloc() - supported
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for memalign
-- Looking for memalign - not found
-- Torch not found. Neural network potential support will be disabled.
-- Using default binary suffix: ""
-- Using default library suffix: ""
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test TEST_ATOMICS
-- Performing Test TEST_ATOMICS - Success
-- Atomic operations found
-- Performing Test PTHREAD_SETAFFINITY
-- Performing Test PTHREAD_SETAFFINITY - Success
-- Detecting best SIMD instructions for this CPU
-- Checking for GCC x86 inline asm
-- Checking for GCC x86 inline asm - supported
-- Detected build CPU features - aes amd apic avx avx2 clfsh cmov cx8 cx16 f16c fma htt lahf misalignsse mmx msr nonstop_tsc pclmuldq pdpe1gb popcnt pse rdrnd rdtscp sha sse2 sse3 sse4a sse4
-- Detected build CPU brand - AMD Ryzen 7 5700X 8-Core Processor
-- Detected build CPU family - 25
-- Detected build CPU model - 33
-- Detected best SIMD instructions for this CPU - AVX2_256
-- Performing Test C_mavx2_mfma_FLAG_ACCEPTED
-- Performing Test C_mavx2_mfma_FLAG_ACCEPTED - Success
-- Performing Test C_mavx2_mfma_COMPILE_WORKS
-- Performing Test C_mavx2_mfma_COMPILE_WORKS - Success
-- Performing Test CXX_mavx2_mfma_FLAG_ACCEPTED
-- Performing Test CXX_mavx2_mfma_FLAG_ACCEPTED - Success
-- Performing Test CXX_mavx2_mfma_COMPILE_WORKS
-- Performing Test CXX_mavx2_mfma_COMPILE_WORKS - Success
-- Enabling 256-bit AVX2 SIMD instructions using CXX flags:  -mavx2 -mfma
-- Detecting flags to enable runtime detection of AVX-512 units on newer CPUs
-- Performing Test C_march_skylake_avx512_FLAG_ACCEPTED
-- Performing Test C_march_skylake_avx512_FLAG_ACCEPTED - Success
-- Performing Test C_march_skylake_avx512_COMPILE_WORKS
-- Performing Test C_march_skylake_avx512_COMPILE_WORKS - Success
-- Performing Test CXX_march_skylake_avx512_FLAG_ACCEPTED
-- Performing Test CXX_march_skylake_avx512_FLAG_ACCEPTED - Success
-- Performing Test CXX_march_skylake_avx512_COMPILE_WORKS
-- Performing Test CXX_march_skylake_avx512_COMPILE_WORKS - Success
-- Detecting flags to enable runtime detection of AVX-512 units on newer CPUs -  -march=skylake-avx512
-- Performing Test _Wno_unused_command_line_argument_FLAG_ACCEPTED
-- Performing Test _Wno_unused_command_line_argument_FLAG_ACCEPTED - Success
-- Performing Test _callconv___vectorcall
-- Performing Test _callconv___vectorcall - Failed
-- Performing Test _callconv___regcall
-- Performing Test _callconv___regcall - Failed
-- Performing Test _callconv_
-- Performing Test _callconv_  - Success
-- Found CUDAToolkit: /opt/cuda/targets/x86_64-linux/include (found suitable version "12.8.61", minimum required is "12.1")
-- Adding work-around for issue compiling CUDA code with glibc 2.23 string.h
-- Check for working NVCC/C++ compiler combination with nvcc ''
-- Check for working NVCC/C++ compiler combination - works
-- Checking if nvcc accepts flags --generate-code=arch=compute_50,code=sm_50
-- Checking if nvcc accepts flags --generate-code=arch=compute_50,code=sm_50 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_52,code=sm_52
-- Checking if nvcc accepts flags --generate-code=arch=compute_52,code=sm_52 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_60,code=sm_60
-- Checking if nvcc accepts flags --generate-code=arch=compute_60,code=sm_60 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_61,code=sm_61
-- Checking if nvcc accepts flags --generate-code=arch=compute_61,code=sm_61 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_70,code=sm_70
-- Checking if nvcc accepts flags --generate-code=arch=compute_70,code=sm_70 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_75,code=sm_75
-- Checking if nvcc accepts flags --generate-code=arch=compute_75,code=sm_75 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_80,code=sm_80
-- Checking if nvcc accepts flags --generate-code=arch=compute_80,code=sm_80 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_86,code=sm_86
-- Checking if nvcc accepts flags --generate-code=arch=compute_86,code=sm_86 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_89,code=sm_89
-- Checking if nvcc accepts flags --generate-code=arch=compute_89,code=sm_89 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_90,code=sm_90
-- Checking if nvcc accepts flags --generate-code=arch=compute_90,code=sm_90 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_100,code=sm_100
-- Checking if nvcc accepts flags --generate-code=arch=compute_100,code=sm_100 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_120,code=sm_120
-- Checking if nvcc accepts flags --generate-code=arch=compute_120,code=sm_120 - No
-- Checking if nvcc accepts flags -Wno-deprecated-gpu-targets
-- Checking if nvcc accepts flags -Wno-deprecated-gpu-targets - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_53,code=compute_53
-- Checking if nvcc accepts flags --generate-code=arch=compute_53,code=compute_53 - No
-- Checking if nvcc accepts flags --generate-code=arch=compute_90,code=compute_90
-- Checking if nvcc accepts flags --generate-code=arch=compute_90,code=compute_90 - No
-- Checking if nvcc accepts flags -use_fast_math
-- Checking if nvcc accepts flags -use_fast_math - No
-- Checking if nvcc accepts flags -Xptxas=-warn-double-usage
-- Checking if nvcc accepts flags -Xptxas=-warn-double-usage - No
-- Checking if nvcc accepts flags -Xptxas=-Werror
-- Checking if nvcc accepts flags -Xptxas=-Werror - No
-- Checking if nvcc accepts flags -diag-suppress=177
-- Checking if nvcc accepts flags -diag-suppress=177 - No
CMake Error at /usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake:865 (message):
  Compiling the CUDA compiler identification source file
  "CMakeCUDACompilerId.cu" failed.

  Compiler: /opt/cuda/bin/nvcc

  Build flags:

  Id flags: --keep;--keep-dir;tmp;-ccbin=/usr/bin/c++ -v



  The output was:

  1

  nvcc warning : Support for offline compilation for architectures prior to
  '<compute/sm/lto>_75' will be removed in a future release (Use
  -Wno-deprecated-gpu-targets to suppress warning).

  #$ _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/..

  #$ CICC_PATH=/opt/cuda/bin/../nvvm/bin

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

  #$
  LD_LIBRARY_PATH=/opt/cuda/bin/../lib:/opt/openmpi-4.1.6/lib:/home/vport/orca_6_0_0:


  #$
  PATH=/opt/cuda/bin/../nvvm/bin:/opt/cuda/bin:/home/vport/orca_6_0_0:/home/vport/.bun/bin:/home/vport/.deno/bin:/home/vport/.tmux/plugins/t-smart-tmux-session-manager/bin:/home/vport/.cabal


  #$ 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

  #$ "/usr/bin"/c++ -D__CUDA_ARCH_LIST__=520 -D__NV_LEGACY_LAUNCH -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__=8
  -D__CUDACC_VER_BUILD__=61 -D__CUDA_API_VER_MAJOR__=12
  -D__CUDA_API_VER_MINOR__=8 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1
  -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64
  "CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp4.ii"

  #$ cudafe++ --c++17 --gnu_version=140201 --display_error_number
  --orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name
  "/home/vport/Downloads/gromacs-2025.0/build-gpu/CMakeFiles/3.31.3/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/bin"/c++ -D__CUDA_ARCH__=520 -D__CUDA_ARCH_LIST__=520
  -D__NV_LEGACY_LAUNCH -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__
  -D__NVCC__ "-I/opt/cuda/bin/../targets/x86_64-linux/include"
  -D__CUDACC_VER_MAJOR__=12 -D__CUDACC_VER_MINOR__=8
  -D__CUDACC_VER_BUILD__=61 -D__CUDA_API_VER_MAJOR__=12
  -D__CUDA_API_VER_MINOR__=8 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1
  -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64
  "CMakeCUDACompilerId.cu" -o "tmp/CMakeCUDACompilerId.cpp1.ii"

  #$ "$CICC_PATH/cicc" --c++17 --gnu_version=140201 --display_error_number
  --orig_src_file_name "CMakeCUDACompilerId.cu" --orig_src_path_name
  "/home/vport/Downloads/gromacs-2025.0/build-gpu/CMakeFiles/3.31.3/CompilerIdCUDA/CMakeCUDACompilerId.cu"
  --allow_managed -arch compute_52 -m64 --no-version-ident -ftz=0 -prec_div=1
  -prec_sqrt=1 -fmad=1 --include_file_name "CMakeCUDACompilerId.fatbin.c"
  -tused --module_id_file_name "tmp/CMakeCUDACompilerId.module_id"
  --gen_c_file_name "tmp/CMakeCUDACompilerId.cudafe1.c" --stub_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.stub.c" --gen_device_file_name
  "tmp/CMakeCUDACompilerId.cudafe1.gpu" "tmp/CMakeCUDACompilerId.cpp1.ii" -o
  "tmp/CMakeCUDACompilerId.ptx"

  #$ ptxas -arch=sm_52 -m64 "tmp/CMakeCUDACompilerId.ptx" -o
  "tmp/CMakeCUDACompilerId.sm_52.cubin"

  #$ fatbinary --create="tmp/CMakeCUDACompilerId.fatbin" -64
  --cicc-cmdline="-ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 "
  "--image3=kind=elf,sm=52,file=tmp/CMakeCUDACompilerId.sm_52.cubin"
  "--image3=kind=ptx,sm=52,file=tmp/CMakeCUDACompilerId.ptx"
  --embedded-fatbin="tmp/CMakeCUDACompilerId.fatbin.c"

  #$ "/usr/bin"/c++ -D__CUDA_ARCH__=520 -D__CUDA_ARCH_LIST__=520
  -D__NV_LEGACY_LAUNCH -c -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -Wno-psabi
  "-I/opt/cuda/bin/../targets/x86_64-linux/include" -m64
  "tmp/CMakeCUDACompilerId.cudafe1.cpp" -o "tmp/CMakeCUDACompilerId.o"

  In file included from
  /opt/cuda/targets/x86_64-linux/include/crt/math_functions.h:5978,

                   from /opt/cuda/targets/x86_64-linux/include/crt/common_functions.h:303,
                   from /opt/cuda/bin/../targets/x86_64-linux/include/crt/host_runtime.h:285,
                   from tmp/CMakeCUDACompilerId.cudafe1.stub.c:8,
                   from CMakeCUDACompilerId.cudafe1.stub.c:1:

  /opt/cuda/targets/x86_64-linux/include/crt/math_functions.h:5990:1: error:
  declaration of ‘double sinpi(double)’ has a different exception
  specifier

   5990 | __func__(double sinpi(double a));
        | ^~~~~~~~


  /opt/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h:2556:15:
  note: from previous declaration ‘double sinpi(double) noexcept’

   2556 | extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 sinpi(double x) noexcept (true);
        |               ^~~~~

  /opt/cuda/targets/x86_64-linux/include/crt/math_functions.h:5992:1: error:
  declaration of ‘double cospi(double)’ has a different exception
  specifier

   5992 | __func__(double cospi(double a));
        | ^~~~~~~~


  /opt/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h:2601:15:
  note: from previous declaration ‘double cospi(double) noexcept’

   2601 | extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 cospi(double x) noexcept (true);
        |               ^~~~~

  /opt/cuda/targets/x86_64-linux/include/crt/math_functions.h:6010:1: error:
  declaration of ‘float sinpif(float)’ has a different exception
  specifier

   6010 | __func__(float sinpif(float a));
        | ^~~~~~~~


  /opt/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h:2579:14:
  note: from previous declaration ‘float sinpif(float) noexcept’

   2579 | extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  sinpif(float x) noexcept (true);
        |              ^~~~~~

  /opt/cuda/targets/x86_64-linux/include/crt/math_functions.h:6012:1: error:
  declaration of ‘float cospif(float)’ has a different exception
  specifier

   6012 | __func__(float cospif(float a));
        | ^~~~~~~~


  /opt/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h:2623:14:
  note: from previous declaration ‘float cospif(float) noexcept’

   2623 | extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  cospif(float x) noexcept (true);
        |              ^~~~~~

  # --error 0x1 --





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:131 (CMAKE_DETERMINE_COMPILER_ID)
  cmake/gmxManageCuda.cmake:118 (enable_language)
  CMakeLists.txt:717 (include)


-- Configuring incomplete, errors occurred!

Is this happening because of a newer nvcc version? I read on the website that the latest version should be supported so don’t really know where to go from here.

Hi!

CUDA 12.8 is supported by GROMACS. But, per NVIDIA forums, not all glibc (system-wide low-level library) versions are supported by CUDA:

The proposed workaround there seems fine if you’re okay changing the files in your CUDA installation. Installing an older version of glibc is usually more trouble.

Whichever way you decide to go, after that make sure to clear GROMACS build directory to make sure all compiler checks are rerun.

2 Likes

Hey mate! Thanks for the quick reply!

Worked like a charm! Just if anyone stumbles here because they’re on arch and have the newer CUDA version, here’s what I did:

  • edit /opt/cuda/targets/x86_64-linux/include/crt/math_functions.h
  • remove the noexcept (true) from all trig functions.

Thanks a lot al42and! :)

does it worked? I got a RTX 5090, CUDA 12.8, no sure about how to compile GMX, the gromacs 2025.0 seemed is the only suitable version?

Yes it did work. But I’ll actually also keep the note here that I had a mismatch between my driver version and the cuda version, so I updated everything and then applied the patch that al42and sent here, it then compiled just ok.

thank you, it actually worked, however, in version 2025.0 and RTX 5090, the efficiency does not improve very much(285 ns/day to 294 ns/day)for seem analysis. That is sad…