Skip to content

Commit 9561fca

Browse files
committed
Work around CUDA CCCL __out macro collision on Windows
1 parent 09cbef5 commit 9561fca

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

onnxruntime/cppbuild.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,19 @@ sedinplace 's/-fvisibility=hidden//g' cmake/CMakeLists.txt cmake/adjust_global_c
133133
sedinplace 's:/Yucuda_pch.h /FIcuda_pch.h::g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers.cmake
134134
#sedinplace 's/${PROJECT_SOURCE_DIR}\/external\/cub//g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers.cmake
135135
sedinplace 's/-Xcompiler \/Zc:__cplusplus/-Xcompiler \/Zc:__cplusplus -Xcompiler \/Zc:preprocessor/g' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers_cuda_plugin.cmake
136-
sedinplace '/#include <sal.h>/i\
137-
#ifndef WIN32_LEAN_AND_MEAN\
138-
#define WIN32_LEAN_AND_MEAN\
139-
#endif\
140-
#ifndef NOMINMAX\
141-
#define NOMINMAX\
142-
#endif\
143-
#include <windows.h>
144-
' onnxruntime/core/providers/cuda/cu_inc/cub.cuh
136+
CUDA_HOME_UNIX="$CUDA_HOME"
137+
if command -v cygpath >/dev/null 2>&1; then
138+
CUDA_HOME_UNIX="$(cygpath -u "$CUDA_HOME")"
139+
fi
140+
CUDA_TCGEN05_LD_H="$CUDA_HOME_UNIX/include/cccl/cuda/__ptx/instructions/generated/tcgen05_ld.h"
141+
if [[ -f "$CUDA_TCGEN05_LD_H" ]]; then
142+
echo "Patching CUDA CCCL tcgen05_ld.h from $CUDA_TCGEN05_LD_H"
143+
mkdir -p onnxruntime/cuda/__ptx/instructions/generated
144+
cp "$CUDA_TCGEN05_LD_H" onnxruntime/cuda/__ptx/instructions/generated/tcgen05_ld.h
145+
sedinplace 's/__out/__cccl_out/g' onnxruntime/cuda/__ptx/instructions/generated/tcgen05_ld.h
146+
else
147+
echo "CUDA CCCL tcgen05_ld.h not found at $CUDA_TCGEN05_LD_H"
148+
fi
145149
sedinplace '/CXX>:\/permissive/a\
146150
"$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>"
147151
' cmake/onnxruntime_providers_cuda.cmake cmake/onnxruntime_providers_cuda_plugin.cmake

0 commit comments

Comments
 (0)