How to install GROMACS on Windows | WSL-Ubuntu
- Rajani Karmakar
- Oct 16, 2024
- 2 min read
This post will cover how to install Gromacs on a Windows machine. We will use Windows Subsystem for Linux (WSL 2) to install our Gromacs version 2023.3.
Before starting we need to enable the Windows Subsystem for Linux (WSL) on your Windows 10/11. If you do not have a proper WSL installation, please follow the procedure here. Let's get started now.
We will create an installation directory to keep our installation files tidy. Let's get inside our installation directory. Here, mkdir command creates a directory in the desired location, whereas cd command changes the current directory to the desired location.
~$ mkdir ~/Installations
~$ cd ~/Installations
To download the Gromacs code (tar file) and untar it.
~$ wget https://ftp.gromacs.org/gromacs/gromacs-2023.3.tar.gz
~$ tar -xvf gromacs-2023.3.tar.gz
You should be able to see a folder named gromacs-2023.3, we would get inside that folder and create a new folder named build and cd into the build.
~$ cd gromacs-2023.3
~$ mkdir build
~$ cd build
Before moving on with Gromacs installation, we will install a few requisites.
~$ sudo dnf install cmake # for RHEL-based linux (Fedora, CentOS)
~$ sudo apt install cmake # for Debian-based linux (Ubuntu)
We might also need to install Perl depending on your Linux installation.
~$ sudo dnf install perl # for RHEL-based linux (Fedora, CentOS)
~$ sudo apt install perl # for Debian-based linux (Ubuntu)
To prepare the CMake files for the Gromacs installation (for most users)
~$ cmake .. \
-DGMX_BUILD_OWN_FFTW=ON \
-DREGRESSIONTEST_DOWNLOAD=ON \
-DGMX_GPU=CUDA \
-DCMAKE_INSTALL_PREFIX=/usr/local/installations/gromacs/2023.3/ \
-DCMAKE_C_COMPILER=/usr/bin/gcc-13
-DCMAKE_CXX_COMPILER=/usr/bin/g++-13
If you don't know the location of the C-Compiler (gcc) and CXX-Compiler (g++) executables, you can find the locations using the which command.
~$ which gcc
/usr/bin/gcc
~$ which g++
/usr/bin/g++
~$ which gcc-13
/usr/bin/gcc-13
~$ which g++-13
/usr/bin/g++-13
If you are an advanced user of Gromacs and want to install an MPI-enabled Gromacs. You would need to install mpich or open-MPI. let's consider that we have an installation of open-MPI. Thus, the command for creating CMake file for the Gromacs installation (MPI-version).
~$ module load openmpi
~$ cmake .. \
-DGMX_BUILD_OWN_FFTW=ON \
-DREGRESSIONTEST_DOWNLOAD=ON \
-DGMX_MPI=ON \
-DGMX_GPU=CUDA \
-DCMAKE_INSTALL_PREFIX=/usr/local/installations/gromacs/2023.3/ \
-DCMAKE_C_COMPILER=mpicc
-DCMAKE_CXX_COMPILER=mpicxx
Make the files using single or multiple CPU cores (run any one of the following).
~$ make # for single CPU core
~$ make -j 32 # for using 32 CPU cores
The generated Make files need to be checked for any errors.
~$ make check
Now, we can install our Gromacs to the desired installation directory/location.
~$ sudo make install -j 32
Our Gromacs installation is ready and now we can source our GMXRC files to start using the Gromacs simulation software.
~$ source /usr/local/installation/gromacs/2023.3/bin/GMXRC
NOTE: You have to source the GMXRC file every time you restart the terminal/computer. If you want to find a solution where you can automate this step. You can open your ~/.bashrc file and paste the lines at the end of the file.
I hope this post was useful for you. If so, do give us a thumbs-up to support us at www.kapsid.com. If you have any queries related to this post forward them to info@kapsid.com