Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,26 @@ if (onnxruntime_USE_CUDA)
endif()
find_package(CUDAToolkit REQUIRED)

if(MSVC AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.9
AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0)
foreach(_cuda_include_dir IN LISTS CUDAToolkit_INCLUDE_DIRS)
set(_clusterlaunchcontrol_header
"${_cuda_include_dir}/cuda/__ptx/instructions/generated/clusterlaunchcontrol.h")
if(EXISTS "${_clusterlaunchcontrol_header}")
# CUDA 12.9 uses Windows's 32-bit long for PTX 64-bit operands. Shadow the toolkit
# header with the longlong2 correction shipped by newer CCCL releases.
set(_cuda_12_9_fix_dir "${CMAKE_CURRENT_BINARY_DIR}/cuda_12_9_fix")
ort_patch_cuda_12_9_clusterlaunchcontrol_header(
"${_clusterlaunchcontrol_header}"
"${_cuda_12_9_fix_dir}/cuda/__ptx/instructions/generated/clusterlaunchcontrol.h")
if(EXISTS "${_cuda_12_9_fix_dir}/cuda/__ptx/instructions/generated/clusterlaunchcontrol.h")
include_directories(BEFORE "${_cuda_12_9_fix_dir}")
endif()
break()
endif()
endforeach()
endif()

# Note: The minimum required CUDA version is greater than 11.8.
add_definitions("-DENABLE_BF16")
message(STATUS "CUDA Toolkit version is greater or equal than 11.8, enable -DENABLE_BF16 flag")
Expand Down
17 changes: 17 additions & 0 deletions cmake/external/cuda_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ macro(setup_cuda_compiler)
endif()
endmacro()

function(ort_patch_cuda_12_9_clusterlaunchcontrol_header src dst)
if(NOT EXISTS "${src}")
return()
endif()

file(READ "${src}" _content)
set(_orig "${_content}")
string(REPLACE "reinterpret_cast<long2*>" "reinterpret_cast<longlong2*>" _content "${_content}")
if(NOT _content STREQUAL _orig)
get_filename_component(_dst_dir "${dst}" DIRECTORY)
file(MAKE_DIRECTORY "${_dst_dir}")
file(WRITE "${dst}" "${_content}")
elseif(EXISTS "${dst}")
file(REMOVE "${dst}")
endif()
endfunction()

macro(setup_cuda_architectures)
# cmake-format: off
# Initialize and normalize CMAKE_CUDA_ARCHITECTURES before enabling CUDA.
Expand Down
Loading