Skip to content

Commit 11f478f

Browse files
authored
[cherry-pick 2.4]fix compil error on windows for cuda11.6/7/8 (#50205)
1 parent edd0541 commit 11f478f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ if(WIN32)
155155
endforeach()
156156
endif()
157157

158-
# NOTE(zhouwei): msvc max/min macro conflict with std::min/max, define NOMINMAX globally
158+
# msvc max/min macro conflict with std::min/max, define NOMINMAX globally
159159
add_definitions("-DNOMINMAX")
160+
161+
# 1. windows.h define 'small' cause CUDA11.6/11.7/11.8 's cub compile error,
162+
# see https://github.com/microsoft/onnxruntime/issues/11227
163+
# 2. WIN32_LEAN_AND_MEAN minimize the windows include files, avoid define 'small'
164+
add_definitions(-DWIN32_LEAN_AND_MEAN)
165+
160166
# windows build turn off warnings, use parallel compiling.
161167
foreach(
162168
flag_var

cmake/external/cub.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
include(ExternalProject)
1616

17-
# Note(zhouwei): extern_cub has code __FILE_, If the path of extern_cub is changed,
17+
# extern_cub has code __FILE_, If the path of extern_cub is changed,
1818
# it will effect about 30+ cu files sccache hit and slow compile speed on windows.
1919
# Therefore, a fixed CUB_PATH will be input to increase the sccache hit rate.
2020
set(CUB_PATH
@@ -25,7 +25,7 @@ set(CUB_PREFIX_DIR ${CUB_PATH})
2525
set(CUB_REPOSITORY ${GIT_URL}/NVlabs/cub.git)
2626

2727
if(${CMAKE_CUDA_COMPILER_VERSION} GREATER_EQUAL 11.6)
28-
# cuda_11.6.2_511.65‘s own cub is 1.15.0, which will cause compiling error in windows.
28+
# cuda_11.6/11.7/11.8‘s own cub is 1.15.0, which will cause compiling error in windows.
2929
set(CUB_TAG 1.16.0)
3030
# cub 1.16.0 is not compitable with current thrust version
3131
add_definitions(-DTHRUST_IGNORE_CUB_VERSION_CHECK)

cmake/third_party.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ if(WITH_ONNXRUNTIME)
317317
endif()
318318

319319
if(WITH_GPU)
320-
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0 OR ${CMAKE_CUDA_COMPILER_VERSION}
321-
GREATER_EQUAL 11.6)
320+
if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0)
322321
include(external/cub) # download cub
323322
list(APPEND third_party_deps extern_cub)
324323
endif()

0 commit comments

Comments
 (0)