Installing GROMACS on Ubuntu with CUDA GPU Support Fails

Ubuntu 22.04
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
GROMACS version: gromacs-2022.2
GROMACS modification: No

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

$ nvidia-smi
Thu Sep 1 18:42:48 2022
±----------------------------------------------------------------------------+
| NVIDIA-SMI 510.85.02 Driver Version: 510.85.02 CUDA Version: 11.6 |
|-------------------------------±---------------------±---------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce … Off | 00000000:42:00.0 On | N/A |
| 27% 35C P8 25W / 250W | 1678MiB / 8192MiB | 5% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+

±----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1760 G /usr/lib/xorg/Xorg 807MiB |
| 0 N/A N/A 2094 G /usr/bin/gnome-shell 126MiB |
| 0 N/A N/A 3613 G …RendererForSitePerProcess 167MiB |
| 0 N/A N/A 98530 C+G ./yasara 163MiB |
| 0 N/A N/A 180148 G …030562158609341530,131072 403MiB |
| 0 N/A N/A 466910 G gnome-control-center 2MiB |
±----------------------------------------------------------------------------+

I am following Installation guide — GROMACS 2022.2 documentation

$ sudo cmake … -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=CUDA

→ Succeeded

$ sudo make
[ 26%] Built target scanner
[ 26%] Generating baseversion-gen.cpp
[ 26%] Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/domdec/libgromacs_generated_gpuhaloexchange_impl.cu.o
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘…’:
435 | function(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:435:145: note: ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘…’:
530 | operator=(_Functor&& __f)
| ^
/usr/include/c++/11/bits/std_function.h:530:146: note: ‘_ArgTypes’
CMake Error at libgromacs_generated_gpuhaloexchange_impl.cu.o.Release.cmake:280 (message):
Error generating file
/home/faruqe/Downloads/gromacs-2022.2/build-gpu/src/gromacs/CMakeFiles/libgromacs.dir/domdec/./libgromacs_generated_gpuhaloexchange_impl.cu.o

make[2]: *** [src/gromacs/CMakeFiles/libgromacs.dir/build.make:133: src/gromacs/CMakeFiles/libgromacs.dir/domdec/libgromacs_generated_gpuhaloexchange_impl.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4883: src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

But If I install using apt-get with sudo apt-get install gromacs command, gromacs installed properly without GPU support (CUDA)

How can I build gromacs with GPU support ?

Hi faruqe!

It is a known issue with recent CUDA and GCC 11.x. We’ll add it to the official list of known issues in the next release of GROMACS :).

As a solution, you can install g++-9 and use it (cmake -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=CUDA -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9).

Sidenote: it is usually excessive and not very secure to run cmake and make with sudo. Only make install requires it. But that is not related to the issue you’re observing.