Building Gromacs on Windows.

Questions and Answers : Windows : Building Gromacs on Windows.

To post messages, you must log in.

AuthorMessage
langfod

Send message
Joined: 3 Aug 17
Posts: 19
Credit: 4,368,403
RAC: 1,416
Message 5124 - Posted: 21 Oct 2017, 22:18:18 UTC
Last modified: 21 Oct 2017, 22:21:43 UTC

First - this is neither supported, sanctioned or approved by Krzysztof Piszczek .
Second - the options, libraries and paths matched my system and probably will not on yours.
Fourth - the resulting files have not been benchmarked and are probably big, slow and likely to catch your house on fire.
Fifth - I probably missed some steps and it might not work anyway - oh well


Tools/Libraries I used:

1) Visual Studio 2017
2) Cmake https://cmake.org/download/
3) Intel MKL libraries https://software.intel.com/en-us/mkl
4) Nvidia CUDA Toolkit https://developer.nvidia.com/cuda-downloads
5) Gromacs source and documentation from http://manual.gromacs.org/documentation/

READ THIS: http://manual.gromacs.org/documentation/2016.4/install-guide/index.html#doing-a-build-of-gromacs

Unpack the Gromacs source.
Open a Visual Studio Dev Shell

cd into your new gromacs-2016.4 directory

Edit src\gromacs\mdlib\nbnxn_cuda\nbnxn_cuda_kernel_utils.cuh
- Change these two lines 79-80:
static const float        c_oneSixth    = 0.16666667f;
static const float        c_oneTwelveth = 0.08333333f;

to
static const __device__ float        c_oneSixth    = 0.16666667f;
static const __device__ float        c_oneTwelveth = 0.08333333f;


make a build directory - this can really be anywhere you like:
mkdir build64

cd build64


(inside of your build directory)

cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_GENERATOR_TOOLSET=v141 -DGMX_FFT_LIBRARY=mkl -DMKL_INCLUDE_DIR="C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/include/" -DMKL_LIBRARIES="C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_intel_thread.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_core.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_intel_ilp64.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_sequential.lib" -DGMX_GPU=on -DGMX_BUILD_SHARED_EXE=OFF -DCUDA_VERBOSE_BUILD=on  -DCUDA_HOST_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe" -DGMX_SIMD=AVX2_256  -DGMX_USE_NVML=off


(yup that was one line - cmake-gui should also work if you prefer checkboxes)

Edit CMakeCache.txt and change the RELEASE build to use static linking (/MT):
CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG

to
CMAKE_CXX_FLAGS_RELEASE:STRING=/MT /O2 /Ob2 /DNDEBUG


(optionaly add /MP to the CMAKE_CXX_FLAGS line for multithreaded build)

again run (this should be quick):

cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_GENERATOR_TOOLSET=v141 -DGMX_FFT_LIBRARY=mkl -DMKL_INCLUDE_DIR="C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/include/" -DMKL_LIBRARIES="C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_intel_thread.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_core.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_intel_ilp64.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_sequential.lib" -DGMX_GPU=on -DGMX_BUILD_SHARED_EXE=OFF -DCUDA_VERBOSE_BUILD=on  -DCUDA_HOST_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe" -DGMX_SIMD=AVX2_256  -DGMX_USE_NVML=off


cd ..

(inside the of the main gromacs source directory agian)
(note that "build64" refers to the directory you created above)

cmake --build build64 --config Release  


With luck you should end up with gmx.exe in build64\bin\Release
ID: 5124 · Rating: 0 · rate: Rate + / Rate - Report as offensive    Reply Quote
mmonnin

Send message
Joined: 25 Jan 17
Posts: 34
Credit: 6,961,791
RAC: 1,471
Message 5128 - Posted: 22 Oct 2017, 4:37:23 UTC - in response to Message 5124.  

How does it compared to the stock app?
ID: 5128 · Rating: 0 · rate: Rate + / Rate - Report as offensive    Reply Quote
noxcivi

Send message
Joined: 25 Sep 17
Posts: 9
Credit: 66,637
RAC: 39
Message 5145 - Posted: 30 Oct 2017, 10:04:29 UTC

Cool guide, langfod. I was happy to see someone else tried compiling on windows. What I did not get is why you set up cmake with Visual Studio 15 2017 but linked VS 14 2015 as cuda host compiler?

Finally I got a version, that utilizes my GTX970 at least as good as the official version does. Only difference being, that the highest reachable GPU utilization is already reached with a sinle CPU core. nt-values >1 cannot get more out of my GPU. Running more than one gmx instances works fine an increases the gpu utilization.

I used these switches:
cmake .. -G "Visual Studio 15 2017 Win64" -DGMX_BUILD_SHARED_EXE=OFF -DCMAKE_LINKER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx64/x64/link.exe" -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_BUILD_OWN_FFTW=ON  -DGMX_FFT_LIBRARY=mkl -DMKL_LIBRARIES="C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_intel_ilp64.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_sequential.lib;C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018.0.124/windows/mkl/lib/intel64_win/mkl_core.lib" -DMKL_INCLUDE_DIR="%MKLROOT%"\include -DGMX_SIMD=AVX2_256 -DGMX_GPU=on -DCUDA_VERBOSE_BUILD=on -DCUDA_HOST_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin" -DGMX_USE_NVML=off -DCUDA_HOST_COMPILER_OPTIONS="-DMKL_ILP64 -lnvidia-ml"

The last switch probably got ignored by the compiler, as NVML was set to OFF. I simply forgot to remove it.
%MKLROOT% may only work when started in a Intel Compiler 18.0 (for Intel 64 Visual Studio 2017) environment shell.
ID: 5145 · Rating: 0 · rate: Rate + / Rate - Report as offensive    Reply Quote
langfod

Send message
Joined: 3 Aug 17
Posts: 19
Credit: 4,368,403
RAC: 1,416
Message 5148 - Posted: 30 Oct 2017, 18:30:22 UTC - in response to Message 5145.  

Good point on the CUDA linker. It was probably copy/paste error. Getting that far was fun enough :)
It was my first time trying to get Cmake and MSVC working.

On my system it should have been C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.11.25503/bin/Hostx64/x64/cl.exe then.
ID: 5148 · Rating: 0 · rate: Rate + / Rate - Report as offensive    Reply Quote

Questions and Answers : Windows : Building Gromacs on Windows.


©2017 All rights reserved | Design by Digital BioPharm Ltd