From 11f478feeb63793bd6a81f1cb44a6c741490576d Mon Sep 17 00:00:00 2001 From: Zhou Wei <1183042833@qq.com> Date: Mon, 6 Feb 2023 13:26:01 +0800 Subject: [PATCH] [cherry-pick 2.4]fix compil error on windows for cuda11.6/7/8 (#50205) --- CMakeLists.txt | 8 +++++++- cmake/external/cub.cmake | 4 ++-- cmake/third_party.cmake | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4b2ee08d94..5fcb0b97742 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,8 +155,14 @@ if(WIN32) endforeach() endif() - # NOTE(zhouwei): msvc max/min macro conflict with std::min/max, define NOMINMAX globally + # msvc max/min macro conflict with std::min/max, define NOMINMAX globally add_definitions("-DNOMINMAX") + + # 1. windows.h define 'small' cause CUDA11.6/11.7/11.8 's cub compile error, + # see https://github.com/microsoft/onnxruntime/issues/11227 + # 2. WIN32_LEAN_AND_MEAN minimize the windows include files, avoid define 'small' + add_definitions(-DWIN32_LEAN_AND_MEAN) + # windows build turn off warnings, use parallel compiling. foreach( flag_var diff --git a/cmake/external/cub.cmake b/cmake/external/cub.cmake index de66e8d63d0..de4e04e6202 100644 --- a/cmake/external/cub.cmake +++ b/cmake/external/cub.cmake @@ -14,7 +14,7 @@ include(ExternalProject) -# Note(zhouwei): extern_cub has code __FILE_, If the path of extern_cub is changed, +# extern_cub has code __FILE_, If the path of extern_cub is changed, # it will effect about 30+ cu files sccache hit and slow compile speed on windows. # Therefore, a fixed CUB_PATH will be input to increase the sccache hit rate. set(CUB_PATH @@ -25,7 +25,7 @@ set(CUB_PREFIX_DIR ${CUB_PATH}) set(CUB_REPOSITORY ${GIT_URL}/NVlabs/cub.git) if(${CMAKE_CUDA_COMPILER_VERSION} GREATER_EQUAL 11.6) - # cuda_11.6.2_511.65‘s own cub is 1.15.0, which will cause compiling error in windows. + # cuda_11.6/11.7/11.8‘s own cub is 1.15.0, which will cause compiling error in windows. set(CUB_TAG 1.16.0) # cub 1.16.0 is not compitable with current thrust version add_definitions(-DTHRUST_IGNORE_CUB_VERSION_CHECK) diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 02c5bc3602f..f4284c84214 100755 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -317,8 +317,7 @@ if(WITH_ONNXRUNTIME) endif() if(WITH_GPU) - if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0 OR ${CMAKE_CUDA_COMPILER_VERSION} - GREATER_EQUAL 11.6) + if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0) include(external/cub) # download cub list(APPEND third_party_deps extern_cub) endif() -- GitLab