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.
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 :)
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.
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.
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})
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.