How to install GROMACS in Windows in "Native" Environment

 

Updated: 2021/06/20

 

This document briefly introduces how to intsall the GROMACS in Windows without Cygwin or Window subsystem for Linux (WSL), by using Visual Studio: "Native" environment, which is enable to use GPU (CUDA) computation.

(I am not sure that Cygwin or WSL can use the Windows' CUDA environment or GPU driver. If you don't need the CUDA environment, or CUDA environment is working properly in the Cygwin or WSL, you can just follow up the "Quick and Dirty Installation" described in GROMACS hompage)

Update: In the developer version of Windows 10, WSL 2 provides CUDA environment. If you are interested in this topic, please check the NVidia homepage. However, I did not test that WSL environment can perform GPU computation in GROMACS. Soon or later, I will test it.

 

Are you very busy?


I precompiled the GROMACS 2021.2 version, under Windows 10 64bit, VS 2019, CUDA 11.3, and FFTW 3.3.5 environment.

You can download it via this link. (~186MB, ZIP file)

Usage: Unzip this file with appropriate destination, and run the gromacs.bat

*Note: If your CPU or GPU is older than mine or using AMD CPU or GPU, GROMACS may not be running properly. In that case, you have to compile your own GROMACS, under your local machine.

My CPU and GPU models are:

1) CPU: Intel i7-6700K (6th Generation)

2) GPU: NVidia GeForce GTX 1080Ti

The detailed information of this precompiled GROMACS is given in this link, which contains output of gmx --version.

 

Prerequisite


To install the GROMACS in Windows system, you need these programs:

1. Visual Studio 2008 or higher version

You can use the "express version" for installation of GROMACS. However, GROMACS 2016 or higher version, one needs to install Visual studio 2017 (VS2017) or higher version, Visual Studio 2019 (VS2019). Check the details about prerequisites in the GROMACS hompage: http://www.gromacs.org

Important note: if you want to use GPU computation with CUDA environment, you should install appropriate Visual Studio Community or higher edition (Professional, Enterprise). (One should install the Visual C++ environment. Check the details about the CUDA environment in NVidia homepage)

** Note: You can also use the Intel C/C++ compiler, (use -T option in cmake) or another compiler or IDE environment to build the GROMACS.

 

2. Cmake

You can easily get via https://cmake.org

 

3. FFTW library or Intel Math Kernel Library (MKL)

You can get from http://www.fftw.org

Please follow steps described in FFTW homepage. (I recommend to download precompiled version)

(You may need to enter some command line (lib) to utilize FFTW library. Check the "Troubleshooting" section, which is located in the bottom of this page.)

 

If you want to use Intel MKL, you can get from the Intel website.

Either FFTW library or Intel MKL is necessary to install the GROMACS.

** Note: When I use to build project with Intel C++ Compiler 16.1, it causes some weird error when I select the mkl library. (/Qmkl:sequential does not work) I recommend to use fftw3.

 

Optional:

1. CUDA for NVidia GPU

You can get through https://developer.nvidia.com/cuda-downloads

2. Any QM program, if you want to perform QM/MM simulation

From now on, GROMACS supports Gaussian, Mopac, Gamess, and Orca

3. MPI Environment

If you want to compute the simulation with MPI, you should install this program, such as MS-MPI or Intel MPI.

 

Procedure


1. Download the GROMACS source code and unzip somewhere.

2. Run CMake GUI

3. Set the source code directory in "Where is the source code"

If you unzip the GROMACS in C:\Users\<Username>\Documents\Gromacs, set this directory.

4. Set a different location to put the built GROMACS in "Where to build the binaries"

For example, you can make a directory named "build", and you can set this location.

5. Click Configure. It will take serveral minutes (around 1~5 mins).

The cmake will ask to select the generator. Find the generator you have installed (Visual studio or any other compilers). If you want to configure 64bit GROMACS, you should select the 64-bit compiler. (Most of cases, it automatically selects default compiler.)

6. Configure will stop because it cannot find FFTW. Don't be panic: just click the "Advanced" check box

 

** If you want to use fftw library, follow this procedure.

6-1. Find out FFTWF_INCLUDE_DIR and FFTWF_LIBRARY option.

6-2. Select FFTW_INCLUDE_DIR as the directory that contains the fftw library file

6-3. Select FFTWF_LIBRARY as "libfftw3f-3.lib".

If you can't find the libffw3f-3.lib file, please check the "Troubleshooting" section, located in bottom of this page.

 

** If you want to use Intel MKL, follow this procedure.

6-1. Find the GMX_FFT_LIBRARY, and select mkl

6-2. Click the configure. Then it will stop again.

6-3. Search the MKL_INCLUDE_DIR and MKL_LIBRARIES variables. Set the MKL_INCLUDE_DIR as the mkl include directory.

In my case, it is C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/include/ (This path can change!)

6-4. Set the MKL_LIBRARIES.

In my case, for the 32bit system, C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/lib/ia32_win/mkl_rt.lib,

for the 64bit system, C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/lib/intel64_win/mkl_rt.lib

 

****** This is optional part

7-1. If you want to configure the QM/MM feature, find the GMX_QMMM_PROGRAM and select the QM program you want.

 

7-2. If you want to use GPU computation, find the GMX_GPU and select the appropriate option. (CUDA or OpenCL)

 

7-3. If you want to enable the MPI, find the GMX_MPI and check the box. (You need to install MS MPI or other software)

*****************************

 

8. Click Configure button.

9. After finishing configure, click Generate button.

10. Open the visual studio, and find the "gromacs.sln" file in the main build directory.

11. Build the project. It will take several minutes. Especially, this procedure will take more than 10 minutes when using nvcc.

(Note: The default build option in the visual studio is Debug. If you want to make release build (for another computer) select Build-configuration manager-Active solution configuration and change Debug to Release)

※ If you run the Visual Studio as administrator, you don't need to do step 12 to 18. The GROMACS will be installed in C:\Program Files (x86)\Gromacs automatically.

 

12. After build the project, you may need to move the some files in the proper location. I set the default location as C:\Gromacs\

13. Make the directory bin, and copy the gmx.exe to the C:\Gromacs\bin

14. Copy the gmx.exe in build\bin\Release

15. Copy some *.dll files needed to execute the gmx program.

- For FFTW case, you need to copy libfftw3f-3.dll

- For MKL case, you need to copy those dll files: (I will update this part soon)

  1) 

16. Make the directory share, and make the directory gromacs in share directory: C:\Gromacs\share\gromacs\

17. Copy the all contents in the share directory in the source code directory. i.e., template, top, etc.

18. Make the directory lib, and copy the gromacs.lib in build\lib\Release

19. Make the *.bat file, which contains this content:

@echo off
set PATH=C:\Gromacs\bin;%PATH%
set GMXDATA=C:\Gromacs\share\gromacs
CALL cmd

 

20. Enjoy!

 

** Note:

- If you want to build your own analyzing program generated by GROMACS (binary files such as *.xtc or *.trr), you need to set "include" directory  (example: -I C:\Gromacs\include), "lib" directory (example: -L C:\Gromacs\lib), and gromacs.lib (-lgromacs) file.

 

Troubleshooting


1. If you cannot find libfftw3f-3.lib file, follow this step (This is described in FFTW webpage: http://www.fftw.org/install/windows.html)

(This step is valid for x64 environment. For other environments, check the FFTW webpage.)

1) Click the start menu, and find "x64 Native Tools Command Prompt for VS 2019 (or another version of Visual Studio)", and run this program. It will show cmd environment.

2) Go to the FFTW folder

3) Enter this command: lib /machine:x64 /def:libfftw3f-3.def

4) Check the libfftw3f-3.lib is created.

 

2. For the recent version of GROMACS (GROMACS 2021.2, released May 5th, 2021), when you try to build the GROMACS with CUDA environment, libgromacs may not build properly, showing this error. It reads as (or like)

nvcc fatal: Unknown option -std:c++17

To fix this, follow this method:

1) Open the file gmxManageNvccConfig.cmake in gromacs-2021.2\cmake

2) Find the CMAKE_CXX17_STANDARD_COMPILE_OPTION (it locates 175th line)

3) Replace CXX as CUDA: CMAKE_CUDA17_STANDARD_COMPILE_OPTION

4) Optional: You can change other CXX14 or CXX17 as CUDA14 or CUDA17, respectively.

5) Save, and reconfigure using cmake GUI program.

 

3. In some cases, the CMake program cannot detect the installed NVidia GPU. For this case, please follow this step:

1) Find the 'nvidia-smi' program in your computer.

2) Using the control pannel, add the above location in PATH variable.

3) Open the file gromacs-(version)\cmake\gmxDetectGpu.cmake

4) In line 92, change exec_progam(${_nvidia_smi_path} ARGS -L as exec_program(nvidia-smi ARGS -L

5) Run the configure again.

 

4. When you building the project (or compile through the Visual Studio), it can show some messages like this:

error C4996: '***': This function or variable may be unsafe. Considering using **** instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

Then you can bypass this error by doing these steps:

1) Find the tng_io_obj project in Solution Explorer

2) Right click the tng_io_obj project, and select Property

3) In the Property page, Find C/C++ and Preprocessor

4) Add the preprocessor definition, _CRT_SECURE_NO_WARNINGS

5) Build the project

 

GROMACS_guestbook - Center for Chemical Dynamics in Living Cells

Leave your comment