Installation (WIN10) error: value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'

GROMACS version: 2023.2
GROMACS modification: No
OS: Windows 10 64 bit
GPU: GTX 1050

CMake command (newlines inserted for ease of reading):

cd C:\Users\Nicolas\Documents\Gromacs\gromacs-2023.2\build

cmake .. -G "Visual Studio 17 2022" 
-A x64 
-DCMAKE_INSTALL_PREFIX=C:\Users\Nicolas\Documents\Gromacs\GMX 
-DGMX_BUILD_OWN_FFTW=OFF  
-DGMX_FFT_LIBRARY=fftw3 
-DFFTWF_LIBRARY="C:\Users\Nicolas\Documents\Gromacs\fftw-install\lib\fftw3f.lib" 
-DFFTWF_INCLUDE_DIR="C:\Users\Nicolas\Documents\Gromacs\fftw-install\include" 
-DREGRESSIONTEST_DOWNLOAD=ON 
-DGMX_GPU=CUDA 
-DGMX_CUDA_TARGET_SM=61 
-DGMX_BUILD_SHARED_EXE=OFF

cmake --build . --config Release --parallel

The error I receive is

gromacs.lib(libgromacs_generated_detecthardware.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value
 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in gmx.obj [C:\Users\Nicolas\Documents\Gromacs\gromacs-2023
.2\build\src\programs\gmx.vcxproj]

There are a total of 49 of the linker errors.

I’ve also tried building without the -DGMX_BUILD_SHARED_EXE=OFF flag but I get the same error.

I see this post here (Link error when building Gromacs on windows with CUDA - #2 by SeLarin) mentions changing a certain cmake variable but I do not know which cmake file I should be making the changes in.

Thanks!

Hi!

Here is a more detailed discussion of this problem:
Build fails on windows when cuda is enabled (#4582) ¡ Issues ¡ GROMACS / GROMACS ¡ GitLab. They suggest setting it at the beginning of the top-level CMakeLists.txt file. There might be a few more modifications required, as mentioned there.

If you make it work, please describe (here or in Gitlab) which steps exactly you had to take. We don’t have any Windows + NVIDIA machines in the GROMACS core team, so reports from users are crucial for figuring out the best fix :)

1 Like

Hi,

Thank you for your help!

Adding the following line to the CMakeLists.txt file resulted in a successful build:
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

During previous attempts at building I also received these two errors (not all at once):
nvcc fatal : Unknown option '-std:c++17'
nvcc fatal : Unsupported gpu architecture 'compute_35'

To solve these issues, I built with the flag -DGMX_CUDA_TARGET_SM=61 to target my specific GPU architecture.

I also see you commented here that

However, although I am building GROMACS 2023.2 and it successfully detected CUDA 12.2, I still received the compute_35 error when I did not use the -DGMX_CUDA_TARGET_SM flag.

Great!

Could you please check if, in a clean build directory, you can build without setting DGMX_CUDA_TARGET_SM after replacing this line in cmake/gmxManageNvccConfig.cmake with the following five lines:

if (NOT MSVC)
    list(APPEND GMX_CUDA_NVCC_FLAGS "${CMAKE_CXX17_STANDARD_COMPILE_OPTION}")
else()
    list(APPEND GMX_CUDA_NVCC_FLAGS "-std=c++17")  # See #4582
endif()

Nothing wrong with using GMX_CUDA_TARGET_SM (it also makes the compilation faster), but it would be useful to understand the problem.

I freshly extracted gromacs-2023.2.tar.gz into a new directory (Gromacs-Test) and performed the modification you mentioned on that cmake file.

This first cmake command succeeded without errors. I removed the DGMX_CUDA_TARGET_SM flag as requested.

cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_INSTALL_PREFIX=C:\Users\Nicolas\Documents\Gromacs-Test\GMX -DGMX_BUILD_OWN_FFTW=OFF  -DGMX_FFT_LIBRARY=fftw3 -DFFTWF_LIBRARY="C:\Users\Nicolas\Documents\Gromacs-Test\fftw-install\lib\fftw3f.lib" -DFFTWF_INCLUDE_DIR="C:\Users\Nicolas\Documents\Gromacs-Test\fftw-install\include" -DREGRESSIONTEST_DOWNLOAD=ON -DGMX_GPU=CUDA -DGMX_BUILD_SHARED_EXE=OFF

However, the second cmake command (unsure what the proper names for these commands are) failed.
cmake --build . --config Release --parallel

Below is the abbreviated output.

  Generating release version information
  Building Custom Rule C:/Users/Nicolas/Documents/Gromacs-Test/gromacs-2023.2/CMakeLists.txt
  Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/Release/libgromacs_generated_nbnxm_cud
  a.cu.obj
  nvcc fatal   : Unsupported gpu architecture 'compute_35'
  CMake Error at libgromacs_generated_nbnxm_cuda.cu.obj.Release.cmake:224 (message):
    Error generating
    C:/Users/Nicolas/Documents/Gromacs-Test/gromacs-2023.2/build/src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/Relea
  se/libgromacs_generated_nbnxm_cuda.cu.obj

I have not touched the directory after this should you want to view some of the intermediate files.

Thank you for checking!

So, the problem is that we were skipping the compiler flag check on Windows during CMake run, and, with CUDA 12, it became a problem at compile time.

One more thing to try: could you please edit cmake/gmxManageNvccConfig.cmake to remove AND NOT WIN32 and OR WIN32 from lines 134 and 168, respectively? Again, in a clean directory.

Before:

    # If the check has already been run, do not re-run it
    if (NOT ${_flags_cache_variable_name} AND NOT WIN32)
        message(STATUS "Checking if nvcc accepts flags ${ARGN}")

.....

    # Append the flags to the output variable if they have been tested to work
    if (${_flags_cache_variable_name} OR WIN32)
        list(APPEND ${_output_variable_name_to_append_to} ${ARGN})

After:

    # If the check has already been run, do not re-run it
    if (NOT ${_flags_cache_variable_name})
        message(STATUS "Checking if nvcc accepts flags ${ARGN}")

.....

    # Append the flags to the output variable if they have been tested to work
    if (${_flags_cache_variable_name})
        list(APPEND ${_output_variable_name_to_append_to} ${ARGN})

Hi,

I removed those conditions from the if statements in that CMake file.

With just that edit, I obtain the following abbreviated output.

Generating release version information
  Building Custom Rule C:/Users/Nicolas/Documents/Gromacs-Test/gromacs-2023.2/CMakeLists.txt
  Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/Release/libgromacs_generated_nbnxm_cud
  a.cu.obj
  nvcc fatal   : Unknown option '-std:c++17'
  CMake Error at libgromacs_generated_nbnxm_cuda.cu.obj.Release.cmake:224 (message):
    Error generating
    C:/Users/Nicolas/Documents/Gromacs-Test/gromacs-2023.2/build/src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/Relea
  se/libgromacs_generated_nbnxm_cuda.cu.obj

With your suggested edits to gmxManageNvccConfig.cmake from both of your posts, the error was the same as in my OP (which makes sense). I might try building again with the CMAKE_MSVC_RUNTIME_LIBRARY variable set properly. Should probably give my laptop a break first though.

Yes, sorry for being unclear. I meant that all the fixes should be combined:

  • APPEND GMX_CUDA_NVCC_FLAGS "-std=c++17" to solve the “Unknown option ‘-std:c++17’” error,
  • CMAKE_MSVC_RUNTIME_LIBRARY to solve the “MT_StaticRelease’ doesn’t match” error,
  • and the change around _flags_cache_variable_name to, hopefully, solve the issue of " Unsupported gpu architecture 'compute_35'" without the need to manually set GMX_CUDA_TARGET_SM.

those are all independent issues.