Configuring GROMACS (patched with PLUMED) with GPU support in Linux

System description

CPU - Intel(R) Core(TM) i7-7500 @2.70 GHz
GPU chip - NVIDIA GeForce 930MX
OS - Ubuntu 16.04 LTS 64 bit

Setting up the NVIDIA driver and CUDA

#Download NVIDIA-Linux-x86_64-384.111.run from  http://www.nvidia.com/Download/driverResults.aspx/128737/en-us
#Download cuda_8.0.61_375.26_linux.run  from https://developer.nvidia.com/cuda-80-ga2-download-archive
#Remove previous versions (if applicable to you)

sudo apt-get --purge remove nvidia-*
sudo nvidia-uninstall

#press ctrl+alt+F2 to go to a tty session and login with your username and password

sudo service lightdm stop

#Blacklist nouveau drivers 
# Create a file named blacklist-nouveau.conf inside /etc/modprobe.d with the following content

blacklist nouveau
options nouveau modeset=0

#Regenerate the kernel initramfs

sudo update initramfs -u

#Run the install script for NVIDIA driver

sudo sh NVIDIA-Linux-x86_64-384.111.run --no-opengl-files

#If --no-opengl-files is not specified above, you will run into a login loop.
#If you get the message that the script failed, choose "continue"
#If you are given the option to register the kernal module sources with DKMS, choose "Yes"
#If you are given the option to install the 32-bit compatibility libraries, choose "No" #Run the install script for CUDA sudo sh cuda_8.0.61_375.26_linux.run --no-opengl-libs
#If you are given the option to install the NVIDIA driver, choose "no"
#Give the preferred location for installation or accept the defaults #Say "yes" for a symbolic link

#Reboot the system by typing

sudo reboot

#Add the cuda-8.0/bin location to the PATH
#Add the cuda-8.0/lib64 location to the LD_LIBRARY_PATH

Installing PLUMED

#Run the following commands for needed software

sudo apt-get install git cmake gawk
sudo apt-get install libmatheval-dev
sudo apt-get install libopenmpi-dev openmpi-bin
sudo apt-get install gnuplot
sudo apt-get install python3 python3-numpy python3-scipy

#Get the location of matheval.h which will later be specified with CPPFLAGS

sudo find / -name matheval.h

#Download PLUMED from http://www.plumed.org/get-it
#Untar the file and do the installation

tar -xvzf plumed-2.4.0.tgz
cd plumed-2.4.0
sudo ./configure CPPFLAGS=-I/usr/include CC=mpicc CXX=mpicxx
make -j 4
sudo make install

GROMACS installation

#Download gromacs 5.1.4 from http://manual.gromacs.org/documentation/5.1.4/download.html
#Untar, patch with PLUMED and install

tar -xvzf gromacs-5.1.4.tar.gz
cd gromacs-5.1.4
plumed patch -p --runtime -e gromacs-5.1.4
mkdir build
cd build

#Find the location of the nvml.h file and specify the directory path under -DNVML_INCLUDE_DIR later with camke

sudo find / -name nvml.h

#Find the location of the libnvidia-ml.so file and specify the file path under -DNVML_LIBRARY later with camke

sudo find / -name libnvidia-ml.so

#Type the below command in the same line.
cmake .. -DGMX_BUILD_OWN_FFTW=on -DGMX_MPI=on -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DGMX_GPU=on -DNVML_INCLUDE_DIR=/usr/local/cuda-8.0/include -DNVML_LIBRARY=/usr/lib/x86_64-linux-gnu/libnvidia-ml.so
make -j 4
make install