GROMACS is a widely used open-source software program designed for molecular dynamics simulations that investigate the behaviour of complex molecular systems. It is known for its high performance and user-friendly interface. It is an excellent choice for simulating various chemical and biochemical systems, including proteins, nucleic acids, lipids, carbohydrates, and polymers.
GROMACS can be installed and used on various operating systems; however, Linux is the most suitable platform due to extensive code testing and better performance.
In this tutorial, I will guide you through the installation of GROMACS on Ubuntu, the most widely used Linux distribution. Additionally, I will explain how to compile the GROMACS source code to create a GPU-enabled version, which allows simulations to run on graphics cards. If your system has a decent NVIDIA graphics card, you can significantly accelerate your simulations with this GPU-enabled version of GROMACS.
Follow me on Linkedin
Note: This blog is the text version of the GROMACS installation video tutorial. You can Watch the video here or on the Insilicosci YouTube channel. You can also copy and paste commands from this page if you prefer not to type them.
Installing GROMACS on Ubuntu using APT package manager
Installing GROMACS on WSL is similar to installing GROMACS on a physical-based Linux.
To start, update the package index list of Ubuntu.
sudo apt update
sudo apt search gromacs
sudo apt install gromacs
After installation, you can check where the GROMACS binary is installed with the following command:
whereis gmx
Installing the NVIDIA CUDA toolkit on Ubuntu
This section is under construction.
wget https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_560.35.05_linux.run
sudo sh cuda_12.6.3_560.35.05_linux.run
echo 'PATH=$PATH:/usr/local/cuda-12.6/bin' >> ~/.bashrc
echo 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.6/lib64' >> ~/.bashrc
Compiling a GPU-enabled GROMACS on Ubuntu
Compiling the source code of GROMACS is another method of installing it. And it is arguably the most challenging method to install GROMACS. So why would someone bother applying this method? This question has three possible answers.
- You may want to compile GROMACS with special features, like the ability to run on GPUs.
- You want to have the latest version of GROMACS.
- You may have a particular Hardware or operating system with no precompiled binary file for them.
sudo apt install -y build-essential gcc vim cmake libpomp-dev hwloc libhwloc-dev
wget -c https://ftp.gromacs.org/gromacs/gromacs-2024.4.tar.gz
tar -xvzf gromacs-2024.4.tar.gz
mkdir gromacs-2024.4/build
cd gromacs-2024.4/build
cmake .. -DGMX_BUILD_OWN_FFTW=ON -DCMAKE_INSTALL_PREFIX=/opt/gromacs-24.4 -DCMAKE_C_COMPILER=gcc -DGMX_GPU=CUDA -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/ -DGMX_HWLOC=ON
make -j 4
sudo make install
echo 'source /opt/gromacs-24.4/bin/GMXRC.bash' >> ~/.bashrc
Running GROMACS simulations on GPU
Download the sample input files from here.
tar -xvzf gromacs_running_test.tgz
cd gromacs_running_test/
gmx grompp -f nvt.mdp -p topol.top -c em.gro -o nvt.tpr -r em.gro -maxwarn 1
gmx mdrun -v -deffnm nvt
Downloads
GROMACS is a free software you can download its source code from the GROMACS website.
To get the GROMACS test simulation input files, click the button below.