Skip to content

Commit 046d06f

Browse files
YUNQIUGUOyufengleegedoensmaxmszhanyiYour Name
authored
Cherry-pick for 1.17.3 (#20013)
### Description <!-- Describe your changes. --> Web prs are not included yet. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Yufeng Li <[email protected]> Co-authored-by: Maximilian Müller <[email protected]> Co-authored-by: Yi Zhang <[email protected]> Co-authored-by: Your Name <[email protected]> Co-authored-by: Edward Chen <[email protected]> Co-authored-by: enximi <[email protected]> Co-authored-by: George Wu <[email protected]> Co-authored-by: Markus Tavenrath <[email protected]> Co-authored-by: Tianlei Wu <[email protected]> Co-authored-by: rachguo <[email protected]> Co-authored-by: Adam Pocock <[email protected]> Co-authored-by: aciddelgado <[email protected]> Co-authored-by: kunal-vaishnavi <[email protected]> Co-authored-by: Changming Sun <[email protected]> Co-authored-by: Chi Lo <[email protected]>
1 parent dbf1a8c commit 046d06f

File tree

67 files changed

+1810
-305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1810
-305
lines changed

VERSION_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.17.2
1+
1.17.3

cmake/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,10 @@ endif()
13961396
if (onnxruntime_USE_CUDA)
13971397
set(CMAKE_CUDA_RUNTIME_LIBRARY Shared)
13981398
set(CMAKE_CUDA_STANDARD 17)
1399+
if(onnxruntime_CUDA_HOME)
1400+
file(TO_CMAKE_PATH CUDAToolkit_ROOT ${onnxruntime_CUDA_HOME})
1401+
endif()
1402+
find_package(CUDAToolkit REQUIRED)
13991403
if(onnxruntime_CUDNN_HOME)
14001404
file(TO_CMAKE_PATH ${onnxruntime_CUDNN_HOME} onnxruntime_CUDNN_HOME)
14011405
endif()

cmake/adjust_global_compile_flags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ endif()
205205

206206

207207
macro(check_nvcc_compiler_flag _FLAG _RESULT)
208-
execute_process(COMMAND ${onnxruntime_CUDA_HOME}/bin/nvcc "${_FLAG}" RESULT_VARIABLE NVCC_OUT ERROR_VARIABLE NVCC_ERROR)
208+
execute_process(COMMAND ${CUDAToolkit_BIN_DIR}/nvcc "${_FLAG}" RESULT_VARIABLE NVCC_OUT ERROR_VARIABLE NVCC_ERROR)
209209
message("NVCC_ERROR = ${NVCC_ERROR}")
210210
message("NVCC_OUT = ${NVCC_OUT}")
211211
if ("${NVCC_OUT}" MATCHES "0")

cmake/external/onnxruntime_external_deps.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,16 +542,15 @@ message("Finished fetching external dependencies")
542542
set(onnxruntime_LINK_DIRS )
543543
if (onnxruntime_USE_CUDA)
544544
#TODO: combine onnxruntime_CUDNN_HOME and onnxruntime_CUDA_HOME, assume they are the same
545+
find_package(CUDAToolkit REQUIRED)
545546
if (WIN32)
546547
if(onnxruntime_CUDNN_HOME)
547548
list(APPEND onnxruntime_LINK_DIRS ${onnxruntime_CUDNN_HOME}/lib ${onnxruntime_CUDNN_HOME}/lib/x64)
548549
endif()
549-
list(APPEND onnxruntime_LINK_DIRS ${onnxruntime_CUDA_HOME}/x64/lib64)
550550
else()
551551
if(onnxruntime_CUDNN_HOME)
552552
list(APPEND onnxruntime_LINK_DIRS ${onnxruntime_CUDNN_HOME}/lib ${onnxruntime_CUDNN_HOME}/lib64)
553553
endif()
554-
list(APPEND onnxruntime_LINK_DIRS ${onnxruntime_CUDA_HOME}/lib64)
555554
endif()
556555
endif()
557556

cmake/onnxruntime_graph.cmake

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,26 @@ file(GLOB_RECURSE onnxruntime_graph_src CONFIGURE_DEPENDS
77
"${ONNXRUNTIME_ROOT}/core/graph/*.cc"
88
)
99

10-
# create empty list for any excludes
10+
# start with empty training srcs list
11+
set(orttraining_graph_src)
12+
13+
if (onnxruntime_ENABLE_TRAINING_OPS AND NOT onnxruntime_ENABLE_TRAINING)
14+
set(orttraining_graph_src
15+
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.cc"
16+
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.h"
17+
)
18+
endif()
19+
20+
if (onnxruntime_ENABLE_TRAINING)
21+
file(GLOB_RECURSE orttraining_graph_src CONFIGURE_DEPENDS
22+
"${ORTTRAINING_SOURCE_DIR}/core/graph/*.h"
23+
"${ORTTRAINING_SOURCE_DIR}/core/graph/*.cc"
24+
)
25+
endif()
26+
27+
# create empty lists for any excludes
1128
set(onnxruntime_graph_src_exclude_patterns)
29+
set(orttraining_graph_src_exclude_patterns)
1230

1331
if (onnxruntime_MINIMAL_BUILD)
1432
# remove schema registration support
@@ -22,11 +40,18 @@ if (onnxruntime_MINIMAL_BUILD)
2240
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/onnx_function_util.cc"
2341
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/shape_inference_functions.h"
2442
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/shape_inference_functions.cc"
43+
"${ONNXRUNTIME_ROOT}/core/graph/dml_ops/dml_defs.h"
44+
"${ONNXRUNTIME_ROOT}/core/graph/dml_ops/dml_defs.cc"
2545
"${ONNXRUNTIME_ROOT}/core/graph/function_template.h"
2646
"${ONNXRUNTIME_ROOT}/core/graph/function_utils.h"
2747
"${ONNXRUNTIME_ROOT}/core/graph/function_utils.cc"
2848
)
2949

50+
list(APPEND orttraining_graph_src_exclude_patterns
51+
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.h"
52+
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.cc"
53+
)
54+
3055
# no Function support initially
3156
list(APPEND onnxruntime_graph_src_exclude_patterns
3257
"${ONNXRUNTIME_ROOT}/core/graph/function*"
@@ -64,30 +89,12 @@ endif()
6489
file(GLOB onnxruntime_graph_src_exclude ${onnxruntime_graph_src_exclude_patterns})
6590
list(REMOVE_ITEM onnxruntime_graph_src ${onnxruntime_graph_src_exclude})
6691

67-
file(GLOB_RECURSE onnxruntime_ir_defs_src CONFIGURE_DEPENDS
68-
"${ONNXRUNTIME_ROOT}/core/defs/*.cc"
69-
)
70-
71-
if (onnxruntime_ENABLE_TRAINING_OPS AND NOT onnxruntime_ENABLE_TRAINING)
72-
set(orttraining_graph_src
73-
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.cc"
74-
"${ORTTRAINING_SOURCE_DIR}/core/graph/training_op_defs.h"
75-
)
76-
endif()
77-
78-
if (onnxruntime_ENABLE_TRAINING)
79-
file(GLOB_RECURSE orttraining_graph_src CONFIGURE_DEPENDS
80-
"${ORTTRAINING_SOURCE_DIR}/core/graph/*.h"
81-
"${ORTTRAINING_SOURCE_DIR}/core/graph/*.cc"
82-
)
83-
endif()
84-
85-
set(onnxruntime_graph_lib_src ${onnxruntime_graph_src} ${onnxruntime_ir_defs_src})
8692
if (onnxruntime_ENABLE_TRAINING_OPS)
87-
list(APPEND onnxruntime_graph_lib_src ${orttraining_graph_src})
93+
file(GLOB orttraining_graph_src_exclude ${orttraining_graph_src_exclude_patterns})
94+
list(REMOVE_ITEM orttraining_graph_src ${orttraining_graph_src_exclude})
8895
endif()
8996

90-
onnxruntime_add_static_library(onnxruntime_graph ${onnxruntime_graph_lib_src})
97+
onnxruntime_add_static_library(onnxruntime_graph ${onnxruntime_graph_src} ${orttraining_graph_src})
9198
add_dependencies(onnxruntime_graph onnx_proto flatbuffers::flatbuffers)
9299
onnxruntime_add_include_to_target(onnxruntime_graph onnxruntime_common ${WIL_TARGET} onnx onnx_proto ${PROTOBUF_LIB} flatbuffers::flatbuffers safeint_interface Boost::mp11)
93100

@@ -120,7 +127,7 @@ endif()
120127

121128
set_target_properties(onnxruntime_graph PROPERTIES FOLDER "ONNXRuntime")
122129
set_target_properties(onnxruntime_graph PROPERTIES LINKER_LANGUAGE CXX)
123-
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_graph_src} ${onnxruntime_ir_defs_src})
130+
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_graph_src})
124131
if (onnxruntime_ENABLE_TRAINING_OPS)
125132
source_group(TREE ${ORTTRAINING_ROOT} FILES ${orttraining_graph_src})
126133
endif()

cmake/onnxruntime_providers_cuda.cmake

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,16 @@
156156
endif()
157157

158158
add_dependencies(${target} onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
159-
target_link_libraries(${target} PRIVATE cublasLt cublas cudnn curand cufft ${ABSEIL_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 safeint_interface)
160-
if(onnxruntime_CUDNN_HOME)
161-
target_include_directories(${target} PRIVATE ${onnxruntime_CUDNN_HOME}/include)
162-
target_link_directories(${target} PRIVATE ${onnxruntime_CUDNN_HOME}/lib)
159+
if(onnxruntime_CUDA_MINIMAL)
160+
target_compile_definitions(${target} PRIVATE USE_CUDA_MINIMAL)
161+
target_link_libraries(${target} PRIVATE ${ABSEIL_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 safeint_interface CUDA::cudart)
162+
else()
163+
target_link_libraries(${target} PRIVATE CUDA::cublasLt CUDA::cublas cudnn CUDA::curand CUDA::cufft CUDA::cudart
164+
${ABSEIL_LIBS} ${ONNXRUNTIME_PROVIDERS_SHARED} Boost::mp11 safeint_interface)
165+
if(onnxruntime_CUDNN_HOME)
166+
target_include_directories(${target} PRIVATE ${onnxruntime_CUDNN_HOME}/include)
167+
target_link_directories(${target} PRIVATE ${onnxruntime_CUDNN_HOME}/lib)
168+
endif()
163169
endif()
164170

165171
if (onnxruntime_USE_TRITON_KERNEL)
@@ -171,25 +177,24 @@
171177
target_include_directories(${target} PRIVATE ${triton_kernel_header_dir})
172178
target_link_libraries(${target} PUBLIC -Wl,--whole-archive ${triton_kernel_obj_file} -Wl,--no-whole-archive)
173179
# lib cuda needed by cuLaunchKernel
174-
target_link_libraries(${target} PRIVATE cuda)
180+
target_link_libraries(${target} PRIVATE CUDA::cuda_driver)
175181
endif()
176182

177183
include(cutlass)
178184
target_include_directories(${target} PRIVATE ${cutlass_SOURCE_DIR}/include ${cutlass_SOURCE_DIR}/examples)
179185

180-
target_include_directories(${target} PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${TVM_INCLUDES} PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
186+
target_include_directories(${target} PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} ${TVM_INCLUDES}
187+
PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
181188
# ${CMAKE_CURRENT_BINARY_DIR} is so that #include "onnxruntime_config.h" inside tensor_shape.h is found
182189
set_target_properties(${target} PROPERTIES LINKER_LANGUAGE CUDA)
183190
set_target_properties(${target} PROPERTIES FOLDER "ONNXRuntime")
184191

185192
if (onnxruntime_ENABLE_CUDA_PROFILING) # configure cupti for cuda profiling
186-
target_include_directories(${target} PRIVATE ${onnxruntime_CUDA_HOME}/extras/CUPTI/include)
187-
target_link_directories(${target} PRIVATE ${onnxruntime_CUDA_HOME}/extras/CUPTI/lib64)
188-
target_link_libraries(${target} PRIVATE cupti)
193+
target_link_libraries(${target} PRIVATE CUDA::cupti)
189194
endif()
190195

191-
if (onnxruntime_ENABLE_NVTX_PROFILE AND NOT WIN32)
192-
target_link_libraries(${target} PRIVATE nvToolsExt)
196+
if (onnxruntime_ENABLE_NVTX_PROFILE)
197+
target_link_libraries(${target} PRIVATE CUDA::nvtx3)
193198
endif()
194199

195200
if (onnxruntime_ENABLE_TRAINING_OPS)

cmake/onnxruntime_providers_tensorrt.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
set(BUILD_LIBRARY_ONLY 1)
99
add_definitions("-DONNX_ML=1")
1010
add_definitions("-DONNX_NAMESPACE=onnx")
11-
set(CUDA_INCLUDE_DIRS ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
11+
set(CUDA_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIRS})
1212
set(TENSORRT_ROOT ${onnxruntime_TENSORRT_HOME})
1313
set(OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
1414
set(PROTOBUF_LIBRARY ${PROTOBUF_LIB})
@@ -58,7 +58,7 @@
5858
URL_HASH SHA1=${DEP_SHA1_onnx_tensorrt}
5959
)
6060
if (NOT CUDA_INCLUDE_DIR)
61-
set(CUDA_INCLUDE_DIR ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) # onnx-tensorrt repo needs this variable to build
61+
set(CUDA_INCLUDE_DIR ${CUDAToolkit_INCLUDE_DIRS}) # onnx-tensorrt repo needs this variable to build
6262
endif()
6363
# The onnx_tensorrt repo contains a test program, getSupportedAPITest, which doesn't support Windows. It uses
6464
# unistd.h. So we must exclude it from our build. onnxruntime_fetchcontent_makeavailable is for the purpose.
@@ -102,11 +102,12 @@
102102
onnxruntime_add_include_to_target(onnxruntime_providers_tensorrt onnxruntime_common onnx flatbuffers::flatbuffers Boost::mp11 safeint_interface)
103103
add_dependencies(onnxruntime_providers_tensorrt onnxruntime_providers_shared ${onnxruntime_EXTERNAL_DEPENDENCIES})
104104
if (onnxruntime_USE_TENSORRT_BUILTIN_PARSER)
105-
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE ${trt_link_libs} cudart ${ONNXRUNTIME_PROVIDERS_SHARED} ${PROTOBUF_LIB} flatbuffers::flatbuffers Boost::mp11 safeint_interface ${ABSEIL_LIBS})
105+
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE ${trt_link_libs} ${ONNXRUNTIME_PROVIDERS_SHARED} ${PROTOBUF_LIB} flatbuffers::flatbuffers Boost::mp11 safeint_interface ${ABSEIL_LIBS} PUBLIC CUDA::cudart)
106106
else()
107-
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE ${onnxparser_link_libs} ${trt_link_libs} cudart ${ONNXRUNTIME_PROVIDERS_SHARED} ${PROTOBUF_LIB} flatbuffers::flatbuffers ${ABSEIL_LIBS})
107+
target_link_libraries(onnxruntime_providers_tensorrt PRIVATE ${onnxparser_link_libs} ${trt_link_libs} ${ONNXRUNTIME_PROVIDERS_SHARED} ${PROTOBUF_LIB} flatbuffers::flatbuffers ${ABSEIL_LIBS} PUBLIC CUDA::cudart)
108108
endif()
109-
target_include_directories(onnxruntime_providers_tensorrt PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS} PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
109+
target_include_directories(onnxruntime_providers_tensorrt PRIVATE ${ONNXRUNTIME_ROOT} ${CMAKE_CURRENT_BINARY_DIR} ${eigen_INCLUDE_DIRS}
110+
PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
110111
if(onnxruntime_CUDNN_HOME)
111112
target_include_directories(onnxruntime_providers_tensorrt PRIVATE ${onnxruntime_CUDNN_HOME}/include)
112113
endif()

cmake/onnxruntime_python.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,7 @@ if (WIN32)
283283
get_filename_component(CUDNN_DLL_NAME ${CUDNN_DLL_PATH} NAME_WE)
284284
string(REPLACE "cudnn64_" "" CUDNN_VERSION "${CUDNN_DLL_NAME}")
285285
if(NOT onnxruntime_CUDA_VERSION)
286-
message("Reading json file ${onnxruntime_CUDA_HOME}/version.json")
287-
set(CUDA_SDK_JSON_FILE_PATH "${onnxruntime_CUDA_HOME}/version.json")
288-
file(READ ${CUDA_SDK_JSON_FILE_PATH} CUDA_SDK_JSON_CONTENT)
289-
string(JSON onnxruntime_CUDA_VERSION GET ${CUDA_SDK_JSON_CONTENT} "cuda" "version")
286+
set(onnxruntime_CUDA_VERSION ${CUDAToolkit_VERSION})
290287
message("onnxruntime_CUDA_VERSION=${onnxruntime_CUDA_VERSION}")
291288
endif()
292289
file(APPEND "${VERSION_INFO_FILE}"

cmake/onnxruntime_unittests.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function(AddTest)
6767
if(onnxruntime_USE_CUDA)
6868
#XXX: we should not need to do this. onnxruntime_test_all.exe should not have direct dependency on CUDA DLLs,
6969
# otherwise it will impact when CUDA DLLs can be unloaded.
70-
target_link_libraries(${_UT_TARGET} PRIVATE cudart)
70+
target_link_libraries(${_UT_TARGET} PRIVATE CUDA::cudart)
7171
endif()
7272
target_link_libraries(${_UT_TARGET} PRIVATE ${_UT_LIBS} GTest::gtest GTest::gmock ${onnxruntime_EXTERNAL_LIBRARIES})
7373
endif()
@@ -1275,7 +1275,7 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
12751275
list(APPEND onnxruntime_shared_lib_test_LIBS cpuinfo)
12761276
endif()
12771277
if (onnxruntime_USE_CUDA)
1278-
list(APPEND onnxruntime_shared_lib_test_LIBS cudart)
1278+
list(APPEND onnxruntime_shared_lib_test_LIBS CUDA::cudart)
12791279
endif()
12801280
if (onnxruntime_USE_TENSORRT)
12811281
list(APPEND onnxruntime_shared_lib_test_LIBS ${TENSORRT_LIBRARY_INFER})

docs/python/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ For more information on ONNX Runtime, please see `aka.ms/onnxruntime <https://ak
66

77

88
Changes
9+
10+
1.17.3
11+
^^^^^^
12+
13+
Release Notes : https://github.com/Microsoft/onnxruntime/releases/tag/v1.17.3
914
-------
1015

1116
1.17.2

0 commit comments

Comments
 (0)