Gromacs 2023 GPU support not working for some reason

GROMACS version: 2023
GROMACS modification: No
Here post your question
So I have beee trying to get GPU support for gromacs in my WSL2 Ubuntu system, for a few days and have come up short so I thought I’d try here. I have already run the comands to compile gromacs form source code like on the website as shown:

tar xfz gromacs-2023.1.tar.gz
cd gromacs-2023.1
mkdir build
cd build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
make
make check
sudo make install
source /usr/local/gromacs/bin/GMXRC

but I then realized from watching tutorials on youtube that running Gromacs on GPU is better, so I installed CUDA and recompiled it with the cmake command:

cmake .. -DGMX_GPU=CUDA -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda -DCUDAToolkit_ROOT=/usr/local/cuda

then ran the make and source commands again, then ran gmx --version and got this:

GROMACS version:    2023
Precision:          mixed
Memory model:       64 bit
MPI library:        thread_mpi
OpenMP support:     enabled (GMX_OPENMP_MAX_THREADS = 128)
GPU support:        CUDA
NB cluster size:    8
SIMD instructions:  AVX2_256
CPU FFT library:    fftw-3.3.8-sse2-avx-avx2-avx2_128
GPU FFT library:    cuFFT
Multi-GPU FFT:      none
RDTSCP usage:       enabled
TNG support:        enabled
Hwloc support:      disabled
Tracing support:    disabled
C compiler:         /usr/bin/cc GNU 11.3.0
C compiler flags:   -fexcess-precision=fast -funroll-all-loops -mavx2 -mfma -Wno-missing-field-initializers -O3 -DNDEBUG
C++ compiler:       /usr/bin/c++ GNU 11.3.0
C++ compiler flags: -fexcess-precision=fast -funroll-all-loops -mavx2 -mfma -Wno-missing-field-initializers -Wno-cast-function-type-strict -fopenmp -O3 -DNDEBUG
BLAS library:
LAPACK library:
CUDA compiler:      /usr/local/cuda/bin/nvcc nvcc: NVIDIA (R) Cuda compiler driver;Copyright (c) 2005-2023 NVIDIA Corporation;Built on Mon_Apr__3_17:16:06_PDT_2023;Cuda compilation tools, release 12.1, V12.1.105;Build cuda_12.1.r12.1/compiler.32688072_0
CUDA compiler flags:-std=c++17;--generate-code=arch=compute_50,code=sm_50;--generate-code=arch=compute_52,code=sm_52;--generate-code=arch=compute_60,code=sm_60;--generate-code=arch=compute_61,code=sm_61;--generate-code=arch=compute_70,code=sm_70;--generate-code=arch=compute_75,code=sm_75;--generate-code=arch=compute_80,code=sm_80;--generate-code=arch=compute_86,code=sm_86;--generate-code=arch=compute_89,code=sm_89;--generate-code=arch=compute_90,code=sm_90;-Wno-deprecated-gpu-targets;--generate-code=arch=compute_53,code=sm_53;--generate-code=arch=compute_80,code=sm_80;-use_fast_math;-Xptxas;-warn-double-usage;-Xptxas;-Werror;-D_FORCE_INLINES;-fexcess-precision=fast -funroll-all-loops -mavx2 -mfma -Wno-missing-field-initializers -Wno-cast-function-type-strict -fopenmp -O3 -DNDEBUG
CUDA driver:        11.70
CUDA runtime:       12.10

which made me think that support was enabled, but when I ran this command:

gmx mdrun -deffnm md_0_1 -nb gpu

I got his result:

:-) GROMACS - gmx mdrun, 2023 (-:

Executable:   /usr/local/gromacs/bin/gmx
Data prefix:  /usr/local/gromacs
Working dir:  /mnt/c/Users/jerem/Documents/MD simulations/Lysozyme in Water
Command line:
  gmx mdrun -deffnm md_0_1 -nb gpu


Back Off! I just backed up md_0_1.log to ./#md_0_1.log.18#
Reading file md_0_1.tpr, VERSION 2021.4-Ubuntu-2021.4-2 (single precision)
Note: file tpx version 122, software tpx version 129
Changing nstlist from 10 to 100, rlist from 1 to 1.168


-------------------------------------------------------
Program:     gmx mdrun, version 2023
Source file: src/gromacs/taskassignment/findallgputasks.cpp (line 85)
MPI rank:    2 (out of 20)

Fatal error:
Cannot run short-ranged nonbonded interactions on a GPU because no GPU is
detected.

For more information and tips for troubleshooting, please check the GROMACS
website at Common Errors — GROMACS webpage https://www.gromacs.org documentation

it says not GPU detected but when I run this command:

nvidia-smi

and get:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.85       Driver Version: 517.70       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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 ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   41C    P0    23W /  N/A |      0MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

which makes me think that my Linux subsystem can detect my graphics card my gromacs can’t for some reason?

Can you just run gmx mdrun -deffm md_o_1 and update the log here

Hi!

You compiled GROMACS with CUDA 12.1, yet your driver is for CUDA 11.7.

You have to update your NVIDIA driver or downgrade your CUDA installation. You can find the compatibility matrix in the CUDA docs: 1. CUDA 12.3 Update 1 Release Notes — Release Notes 12.3 documentation

may i know what you did to solve this? i am encountering this same problem

It was what al42and said, it was a problem with the CUDA version gromacs was compiled with and my driver version. I suggest updating your drivers, so you don’t have to recompile gromacs.