-
Notifications
You must be signed in to change notification settings - Fork 2
Resolve CUDA compile check error in CMAKE
Tang, Wenyi edited this page Aug 25, 2018
·
1 revision
In one word:
change #if _MSC_VER < 1600 || _MSC_VER > 1900
to #if _MSC_VER < 1600 || _MSC_VER > 1999
in host_config.h
Using CMake to help compile tensorflow with GPU ops, we first check CUDA compatibility:
try_compile(CUDA_TEST_COMPILE_C
${CMAKE_CURRENT_BINARY_DIR}/tests/cuda
${CMAKE_CURRENT_SOURCE_DIR}/tests/cuda/compatibility_test.c
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS})
try_compile(CUDA_TEST_COMPILE_CXX
${CMAKE_CURRENT_BINARY_DIR}/tests/cuda
${CMAKE_CURRENT_SOURCE_DIR}/tests/cuda/compatibility_test.cc
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS})
In your CUDA installation headers, with a file include/crt/host_config.h
, there is a block
#if defined(_WIN32)
#if _MSC_VER < 1600 || _MSC_VER > 1900
#error -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
#elif _MSC_VER == 1600 /* _MSC_VERION == 1600 */
#pragma message("support for Microsoft Visual Studio 2010 has been deprecated!")
#endif /* _MSC_VER < 1600 || _MSC_VER > 1800 || _MSC_VERSION == 1600 */
#endif /* _WIN32 */
Here they check _MSC_VER
and make sure not less than 1600 or greater than 1900.
The problem is _MSC_VER > 1900
here! In fact the current _MSC_VER
in VS2017 15.8.1 is 1915, while no error was found in my compilation with the version newer than 1900. So you just feel free to change this number to anything greater than 1915!