Running GROMACS MD package on Grex

Introduction#


GROMACS (GROningen MAchine for Chemical Simulations) is a molecular dynamics package primarily designed for simulations of proteins, lipids and nucleic acids. GROMACS is one of the fastest and most popular software packages available and can run on CPUs as well as GPUs.

System specific notes#


On the Grex’s default software stack (SBEnv), GROMACS is built using a variety of compilers and OpenMPI 4.1

To find out which versions are available, use module spider gromacs. There could be more than one (for example, CPU and GPU) builds available for each GROMACS version as listed by module spider.

For a version gromacs/2024.1, at the time of writing the following modules should be loaded for the CPU version:

module load SBEnv
module load arch/avx512 gcc/13.2.0 openmpi/4.1.6
module load gromacs/2024.1

The above module/version gives access to the GROMACS built for compute nodes on GREX, using Intel or AMD AVX512 CPUs.

There is also a CUDA GPU version that would be able to use GPU partitions on Grex. It can be made available by loading modules in the following order:

module load SBEnv
module load cuda/12.4.1  arch/avx2  gcc/13.2.0  openmpi/4.1.6
module load gromacs/2024.1
Script example for running GROMACS on Grex
run-gromacs.sh
#!/bin/bash

#SBATCH --nodes=1                # number of nodes
#SBATCH --ntasks-per-node=26     # request 26 MPI tasks per node
#SBATCH --cpus-per-task=2        # 2 OpenMP threads per MPI task 
#SBATCH --mem-per-cpu=1000M      # memory per CPU (in MB)
#SBATCH --time=0-03:00           # time limit (D-HH:MM)
#SBATCH --job-name=md-test

# Adjust the number of tasks, nodes, threads time and memory required.
# the above spec is for 26 MPI compute tasks each spawning 2 threads = 52 cores per node

# Load the modules for the CPU version using Grex SBEnv environment

module load SBEnv
module load arch/avx512  gcc/13.2.0  openmpi/4.1.6
module load gromacs/2024.1

# If multithreading is required, it has to be passed to the task with OMP_NUM_THREADS

export OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK:-1}"

echo "Starting run at: `date`"
 
srun --cpus-per-task=$OMP_NUM_THREADS gmx_mpi mdrun -deffnm md

echo "Program finished with exit code $? at: `date`"

Assuming the script above is saved as run-espresso.sh, it can be submitted with:

sbatch run-gromacs.sh

For more information, visit the page running jobs on Grex