GROMACS-2023.2 安装(GPU加速)

时间:2025-03-14 08:34:34

预装:

1,cmake3.25.2安装,路径加入到bashrc

2,gcc版本9.3,路径加入到bashrc

3,fftw版本3.3.10

4,Openmpi4.1.1 路径加入到bashrc

5,cuda12.1 路径加入到bashrc(bin、lib、include都要)

(注意bashrc路径要加入在最后一行,否则不生效,天知道什么bug)

一,GPU版本gromacs下载及安装:

​
wget /gromacs/gromacs-2023.
tar xfz gromacs-2023.
cd gromacs-2023.2
mkdir build
cd build
​cmake .. -DCMAKE_INSTALL_PREFIX=/xx/xx/gromacs-2023 -DGMX_BUILD_OWN_FFTW=ON -DGMX_GPU=CUDA  -DGMX_MPI=ON -DCMAKE_C_COMPILER=/path/of/openmpi411/bin/mpicc -DCMAKE_CXX_COMPILER=/path/of/openmpi411/bin/mpic++
make
make install -j8
source /xx/xx/gromacs-2023/bin/GMXRC
gmx --version

cmake失败基本需要删掉build重新cmake。

最后输出结果:

(base) [root@lignin ~]# gmx --version
                         :-) GROMACS - gmx, 2023.2 (-:

Executable:   /opt/gromacs-2023/bin/gmx
Data prefix:  /opt/gromacs-2023
Working dir:  /root
Command line:
  gmx --version

GROMACS version:    2023.2
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:  AVX_512
CPU FFT library:    fftw-3.3.8-sse2-avx-avx2-avx2_128-avx512
GPU FFT library:    cuFFT
Multi-GPU FFT:      none
RDTSCP usage:       enabled
TNG support:        enabled
Hwloc support:      disabled
Tracing support:    disabled
C compiler:         /opt/openmpi411/bin/mpicc GNU 9.3.0
C compiler flags:   -fexcess-precision=fast -funroll-all-loops -mavx512f -mfma -mavx512vl -mavx512dq -mavx512bw -Wno-missing-field-initializers -O3 -DNDEBUG
C++ compiler:       /opt/openmpi411/bin/mpic++ GNU 9.3.0
C++ compiler flags: -fexcess-precision=fast -funroll-all-loops -mavx512f -mfma -mavx512vl -mavx512dq -mavx512bw -Wno-missing-field-initializers -Wno-cast-function-type-strict -fopenmp -O3 -DNDEBUG
BLAS library:
LAPACK library:
CUDA compiler:      /usr/local/cuda-12.1/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;;-fexcess-precision=fast -funroll-all-loops -mavx512f -mfma -mavx512vl -mavx512dq -mavx512bw -Wno-missing-field-initializers -Wno-cast-function-type-strict -fopenmp -O3 -DNDEBUG
CUDA driver:        12.10
CUDA runtime:       12.10

踩过的坑:

报错1:standard error: 'nvcc fatal : Unsupported NVHPC compiler found. nvc++ is the only NVHPC compiler that is supported.

-- /opt/nvidia/nvhpc-23.3/Linux_x86_64/23.1/cuda/11.8/bin/nvcc standard output: ''
-- /opt/nvidia/nvhpc-23.3/Linux_x86_64/23.1/cuda/11.8/bin/nvcc standard error:  'nvcc fatal   : Unsupported NVHPC compiler found. nvc++ is the only NVHPC compiler that is supported.
'
CMake Error at cmake/:105 (message):
  NVCC/C++ compiler combination does not seem to be supported.  CUDA
  frequently does not support the latest versions of the host compiler, so
  you might want to try an earlier C++ compiler version and make sure your
  CUDA compiler and driver are as recent as possible.  Set the GMX_NVCC_WORKS
  CMake cache variable to bypass this check if you know what you are doing.
Call Stack (most recent call first):
  cmake/:105 (include)
  :649 (include)

解决办法:指定openmpi4.1以上的编译器mpicc,mpic++

二、双精度版本

1,重新编译FFTW,编译FFTW时去掉--enable-float:

./configure --prefix=/sob/fftw338 --enable-sse2 --enable-avx --enable-shared
make install -j 24

2,进入gromacs-2023.2/build,清空文件夹,依次输入以下命令,无报错情况下无需指定g++路径:

export CMAKE_PREFIX_PATH=/sob/fftw338
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gromacs-2023 -DGMX_DOUBLE=ON  -DCMAKE_CXX_COMPILER=/usr/lib/gcc/x86_64-redhat-linux/9.3.0/bin/g++
make install -j 24

这里指定g++路径,不然报错如下:

CMake Error in /opt/gromacs-2023/build/CMakeFiles/CMakeTmp/:
  Target "cmTC_97c0f" requires the language dialect "CXX17" .  But the
  current compiler "GNU" does not support this, or CMake does not know the
  flags to enable it.

顺利make之后产生~/bin/gmx_d,直接使用即可,无需重复加入路径。