mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
* First iteration of making cuda a shared provider. Separated out shared OpKernel change, so doing this to merge with that change. * More cuda shared library refactoring * More cuda shared library refactoring * More build options tested, converted the training ops over. * Fix merge breaks * Fix submodules * Fix submodules * Fix submodules * Fix python * Fix compile errors * Duplicate symbol fix * Test fix for ROCM provider * Another ROCM test workaround * ROCM Build Test * ROCM build fix * ROCM * ROCM * ROCM * ROCM * ROCM * ROCM test * Reduce header dependencies * Remove redundant namespace * Test fix for linux * Fix linux build * Fix Eigen build error * Fix unused parameter warning * Test link error * Another linker test * Linker test * Linker test * Another test * Another build test * Fix linux link error * Build test * Fix control flow ops to use common base class with core code * Remove extra qualifiers * Fix template syntax for linux * Fix cuda memory leak * Fix pybind * Test disabling cast * Cleanup * Restore cuda in test * Remove more header dependencies * Test not adding cuda provider to session * Make GetProviderInfo_CUDA throw * No-op cuda provider creation * Fix some setup issues * Fix memory cleanup on unload * Diagnostics * Don't unload library * Add diagnostics * Fix deleting registry at right time. * Test disabling profiler * Fix merge break * Revert profiler change * Move unloading of shared providers into Environment * Free more global allocations before library unloads * Add more diagnostics * Move unloading back to the OrtEnv as there are multiple Environments created during a session. Remove some library dependencies for tests. * Fix more cmake files * ERROR -> WARNING * Fix python shutdown * Test not using dml in pipeline * Change python version and disable dml * Update python version * Test adding unload method for shared providers * Disable DLL test * Python test * Revert "Python test" This reverts commitc7ec2cfe98. * Revert "Disable DLL test" This reverts commite901cb93aa. * Revert "Test adding unload method for shared providers" This reverts commitc427b78799. * Point to RyanWinGPU * Revert python version * Fix id_to_allocator_map * Another python exit test * Remove extra debug messages Try a more clean python shutdown through DllMain * Revert DllMain idea, it didn't work * Merge conflicts * Fix merge with master issues. * Comments * Undo edit to file * Cleanup + new training ops * Revert yml changes * Fix another merge error * ROCM fix * ROCM fix v2 * Put back Linux hack, it is necessary * Stupid fixes * Fix submodule out of sync * ROCM fix 3 * ROCM 4 * Test java fix * Fix typos * Java test on my VM * Fix build error * Spotless fix * Leave temp file around to load properly * Fix cleanup on exit * Fix break * Java comments * Remove LongformerAttentionBase workaround * Spotless fix * Switch yml back to regular build pool * Revert "Switch yml back to regular build pool" This reverts commitbe35fc2a5a. * Code review feedback * Fix errors due to merge * Spotless fix * Fix minimal build * Java fix for non cuda case * Java fix for CPU build * Fix Nuphar? * Fix nuphar 2 * Fix formatting * Revert "Remove LongformerAttentionBase workaround" This reverts commit648679b370. * Training fix * Another java fix * Formatting * Formatting * For orttraining * Last orttraining build fix... * training fixes * Fix test provider error * Missing pass command * Removed in wrong spot * Python typo * Python typos * Python crash on exit, possibly due to unloading of libraries. * Remove test_execution_provider from training build Only enable python atexit on windows Remove assert on provider library exit * Still can't unload providers in python, alas. * Disable Nvtx temporarily * MPI Kernels for Training * MPI Kernels part 2 * Patch through INcclService * Oops, wrong CMakeLists * Missing namespace * Fix missing () * Move INcclService::GetInstance around to link nicer * Missing } * Missing MPI libraries for Cuda * Add extra GetType functions used by MPI * Missing Nccl library * Remove LOGS statements as a test * Add in a couple more missing GetType methods * Update comments * Missed a logging reference in mpi_context.h * Convert aten_op to shared (due to marge with master) * Test moving DistributedRunContext instance into shared provider layer (with purpose error to verify it's being built properly) * Test passed, now with fix * Missing static * Oops, scope DistributedRunContext to just NCCL * Merge related issues and code review feedback. * Merge error * Bump to rel-1.9.1 (#7684) * Formatting * Code review feedback for Java build on non Windows * Remove cupti library dependency from core library * Test Java pipeline fix * Linux build fix * Revert "Linux build fix" This reverts commita73a811516. * Revert "Remove cupti library dependency from core library" This reverts commit6a889ee8bf. * Packaging pipeline fixes to copy cuda shared provider for tensorrt & standard packages * Add cuda to Tensorrt nuget package * onnxruntime_common still has a cuda header dependency Co-authored-by: ashbhandare <ash.bhandare@gmail.com>
207 lines
10 KiB
CMake
207 lines
10 KiB
CMake
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
|
|
set (CXXOPTS ${PROJECT_SOURCE_DIR}/external/cxxopts/include)
|
|
|
|
# training lib
|
|
file(GLOB_RECURSE onnxruntime_training_srcs
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/*.cc"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/tensorboard/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/tensorboard/*.cc"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/adasum/*"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/framework/communication/*"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/session/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/session/*.cc"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/agent/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/core/agent/*.cc"
|
|
)
|
|
|
|
onnxruntime_add_static_library(onnxruntime_training ${onnxruntime_training_srcs})
|
|
add_dependencies(onnxruntime_training onnx tensorboard ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
|
onnxruntime_add_include_to_target(onnxruntime_training onnxruntime_common onnx onnx_proto tensorboard protobuf::libprotobuf flatbuffers)
|
|
|
|
# fix event_writer.cc 4100 warning
|
|
if(WIN32)
|
|
target_compile_options(onnxruntime_training PRIVATE /wd4100)
|
|
endif()
|
|
|
|
target_include_directories(onnxruntime_training PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${eigen_INCLUDE_DIRS} ${RE2_INCLUDE_DIR} PUBLIC ${onnxruntime_graph_header} ${MPI_CXX_INCLUDE_DIRS})
|
|
|
|
if (onnxruntime_USE_CUDA)
|
|
target_include_directories(onnxruntime_training PRIVATE ${onnxruntime_CUDNN_HOME}/include ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
|
|
endif()
|
|
|
|
if (onnxruntime_USE_NCCL)
|
|
target_include_directories(onnxruntime_training PRIVATE ${NCCL_INCLUDE_DIRS})
|
|
endif()
|
|
|
|
set_target_properties(onnxruntime_training PROPERTIES FOLDER "ONNXRuntime")
|
|
source_group(TREE ${ORTTRAINING_ROOT} FILES ${onnxruntime_training_srcs})
|
|
|
|
# training runner lib
|
|
file(GLOB_RECURSE onnxruntime_training_runner_srcs
|
|
"${ORTTRAINING_SOURCE_DIR}/models/runner/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/runner/*.cc"
|
|
)
|
|
|
|
# perf test utils
|
|
set(onnxruntime_perf_test_src_dir ${TEST_SRC_DIR}/perftest)
|
|
set(onnxruntime_perf_test_src
|
|
"${onnxruntime_perf_test_src_dir}/utils.h")
|
|
|
|
if(WIN32)
|
|
list(APPEND onnxruntime_perf_test_src
|
|
"${onnxruntime_perf_test_src_dir}/windows/utils.cc")
|
|
else ()
|
|
list(APPEND onnxruntime_perf_test_src
|
|
"${onnxruntime_perf_test_src_dir}/posix/utils.cc")
|
|
endif()
|
|
|
|
onnxruntime_add_static_library(onnxruntime_training_runner ${onnxruntime_training_runner_srcs} ${onnxruntime_perf_test_src})
|
|
add_dependencies(onnxruntime_training_runner ${onnxruntime_EXTERNAL_DEPENDENCIES} onnx onnxruntime_providers)
|
|
|
|
onnxruntime_add_include_to_target(onnxruntime_training_runner onnxruntime_training onnxruntime_framework onnxruntime_common onnx onnx_proto protobuf::libprotobuf onnxruntime_training flatbuffers)
|
|
|
|
target_include_directories(onnxruntime_training_runner PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${eigen_INCLUDE_DIRS} PUBLIC ${onnxruntime_graph_header})
|
|
target_link_libraries(onnxruntime_training_runner PRIVATE nlohmann_json::nlohmann_json)
|
|
if (onnxruntime_USE_CUDA)
|
|
target_include_directories(onnxruntime_training_runner PUBLIC ${onnxruntime_CUDNN_HOME}/include ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
|
|
endif()
|
|
|
|
if (onnxruntime_USE_NCCL)
|
|
target_include_directories(onnxruntime_training_runner PRIVATE ${NCCL_INCLUDE_DIRS})
|
|
endif()
|
|
|
|
if (onnxruntime_USE_ROCM)
|
|
add_definitions(-DUSE_ROCM=1)
|
|
target_include_directories(onnxruntime_training_runner PUBLIC ${onnxruntime_ROCM_HOME}/include)
|
|
endif()
|
|
|
|
check_cxx_compiler_flag(-Wno-maybe-uninitialized HAS_NO_MAYBE_UNINITIALIZED)
|
|
if(UNIX AND NOT APPLE)
|
|
if (HAS_NO_MAYBE_UNINITIALIZED)
|
|
target_compile_options(onnxruntime_training_runner PUBLIC "-Wno-maybe-uninitialized")
|
|
endif()
|
|
endif()
|
|
|
|
if (onnxruntime_USE_ROCM)
|
|
target_compile_options(onnxruntime_training_runner PUBLIC -D__HIP_PLATFORM_HCC__=1)
|
|
endif()
|
|
|
|
set_target_properties(onnxruntime_training_runner PROPERTIES FOLDER "ONNXRuntimeTest")
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_training_runner_srcs} ${onnxruntime_perf_test_src})
|
|
|
|
|
|
# MNIST
|
|
file(GLOB_RECURSE training_mnist_src
|
|
"${ORTTRAINING_SOURCE_DIR}/models/mnist/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/mnist/mnist_data_provider.cc"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/mnist/main.cc"
|
|
)
|
|
onnxruntime_add_executable(onnxruntime_training_mnist ${training_mnist_src})
|
|
onnxruntime_add_include_to_target(onnxruntime_training_mnist onnxruntime_common onnx onnx_proto protobuf::libprotobuf onnxruntime_training flatbuffers)
|
|
target_include_directories(onnxruntime_training_mnist PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${eigen_INCLUDE_DIRS} ${CXXOPTS} ${extra_includes} ${onnxruntime_graph_header} ${onnxruntime_exec_src_dir} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/onnx onnxruntime_training_runner)
|
|
|
|
set(ONNXRUNTIME_LIBS
|
|
onnxruntime_session
|
|
${onnxruntime_libs}
|
|
${PROVIDERS_ROCM}
|
|
${PROVIDERS_MKLDNN}
|
|
onnxruntime_optimizer
|
|
onnxruntime_providers
|
|
onnxruntime_util
|
|
onnxruntime_framework
|
|
onnxruntime_graph
|
|
onnxruntime_common
|
|
onnxruntime_mlas
|
|
onnxruntime_flatbuffers
|
|
)
|
|
|
|
if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
|
|
list(APPEND ONNXRUNTIME_LIBS onnxruntime_language_interop onnxruntime_pyop)
|
|
endif()
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
if (HAS_NO_MAYBE_UNINITIALIZED)
|
|
target_compile_options(onnxruntime_training_mnist PUBLIC "-Wno-maybe-uninitialized")
|
|
endif()
|
|
endif()
|
|
target_link_libraries(onnxruntime_training_mnist PRIVATE onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_LIBS} ${onnxruntime_EXTERNAL_LIBRARIES})
|
|
set_target_properties(onnxruntime_training_mnist PROPERTIES FOLDER "ONNXRuntimeTest")
|
|
|
|
|
|
# squeezenet
|
|
# Disabling build for squeezenet, as no one is using this
|
|
#[[
|
|
file(GLOB_RECURSE training_squeezene_src
|
|
"${ORTTRAINING_SOURCE_DIR}/models/squeezenet/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/squeezenet/*.cc"
|
|
)
|
|
onnxruntime_add_executable(onnxruntime_training_squeezenet ${training_squeezene_src})
|
|
onnxruntime_add_include_to_target(onnxruntime_training_squeezenet onnxruntime_common onnx onnx_proto protobuf::libprotobuf onnxruntime_training flatbuffers)
|
|
target_include_directories(onnxruntime_training_squeezenet PUBLIC ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${eigen_INCLUDE_DIRS} ${extra_includes} ${onnxruntime_graph_header} ${onnxruntime_exec_src_dir} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/onnx onnxruntime_training_runner)
|
|
if(UNIX AND NOT APPLE)
|
|
target_compile_options(onnxruntime_training_squeezenet PUBLIC "-Wno-maybe-uninitialized")
|
|
endif()
|
|
target_link_libraries(onnxruntime_training_squeezenet PRIVATE onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_LIBS} ${onnxruntime_EXTERNAL_LIBRARIES})
|
|
set_target_properties(onnxruntime_training_squeezenet PROPERTIES FOLDER "ONNXRuntimeTest")
|
|
]]
|
|
|
|
# BERT
|
|
file(GLOB_RECURSE training_bert_src
|
|
"${ORTTRAINING_SOURCE_DIR}/models/bert/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/bert/*.cc"
|
|
)
|
|
onnxruntime_add_executable(onnxruntime_training_bert ${training_bert_src})
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
if (HAS_NO_MAYBE_UNINITIALIZED)
|
|
target_compile_options(onnxruntime_training_bert PUBLIC "-Wno-maybe-uninitialized")
|
|
endif()
|
|
endif()
|
|
|
|
onnxruntime_add_include_to_target(onnxruntime_training_bert onnxruntime_common onnx onnx_proto protobuf::libprotobuf onnxruntime_training flatbuffers)
|
|
target_include_directories(onnxruntime_training_bert PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${MPI_CXX_INCLUDE_DIRS} ${eigen_INCLUDE_DIRS} ${CXXOPTS} ${extra_includes} ${onnxruntime_graph_header} ${onnxruntime_exec_src_dir} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/onnx onnxruntime_training_runner)
|
|
|
|
target_link_libraries(onnxruntime_training_bert PRIVATE onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_LIBS} ${onnxruntime_EXTERNAL_LIBRARIES})
|
|
set_target_properties(onnxruntime_training_bert PROPERTIES FOLDER "ONNXRuntimeTest")
|
|
|
|
# Pipeline
|
|
file(GLOB_RECURSE training_pipeline_poc_src
|
|
"${ORTTRAINING_SOURCE_DIR}/models/pipeline_poc/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/pipeline_poc/*.cc"
|
|
)
|
|
onnxruntime_add_executable(onnxruntime_training_pipeline_poc ${training_pipeline_poc_src})
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
if (HAS_NO_MAYBE_UNINITIALIZED)
|
|
target_compile_options(onnxruntime_training_pipeline_poc PUBLIC "-Wno-maybe-uninitialized")
|
|
endif()
|
|
endif()
|
|
|
|
onnxruntime_add_include_to_target(onnxruntime_training_pipeline_poc onnxruntime_common onnx onnx_proto protobuf::libprotobuf onnxruntime_training flatbuffers)
|
|
target_include_directories(onnxruntime_training_pipeline_poc PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${MPI_CXX_INCLUDE_DIRS} ${eigen_INCLUDE_DIRS} ${CXXOPTS} ${extra_includes} ${onnxruntime_graph_header} ${onnxruntime_exec_src_dir} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/onnx onnxruntime_training_runner)
|
|
if (onnxruntime_USE_NCCL)
|
|
target_include_directories(onnxruntime_training_pipeline_poc PRIVATE ${NCCL_INCLUDE_DIRS})
|
|
endif()
|
|
|
|
target_link_libraries(onnxruntime_training_pipeline_poc PRIVATE onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_LIBS} ${onnxruntime_EXTERNAL_LIBRARIES})
|
|
set_target_properties(onnxruntime_training_pipeline_poc PROPERTIES FOLDER "ONNXRuntimeTest")
|
|
|
|
# GPT-2
|
|
file(GLOB_RECURSE training_gpt2_src
|
|
"${ORTTRAINING_SOURCE_DIR}/models/gpt2/*.h"
|
|
"${ORTTRAINING_SOURCE_DIR}/models/gpt2/*.cc"
|
|
)
|
|
onnxruntime_add_executable(onnxruntime_training_gpt2 ${training_gpt2_src})
|
|
if(UNIX AND NOT APPLE)
|
|
if (HAS_NO_MAYBE_UNINITIALIZED)
|
|
target_compile_options(onnxruntime_training_gpt2 PUBLIC "-Wno-maybe-uninitialized")
|
|
endif()
|
|
endif()
|
|
onnxruntime_add_include_to_target(onnxruntime_training_gpt2 onnxruntime_common onnx onnx_proto protobuf::libprotobuf onnxruntime_training flatbuffers)
|
|
target_include_directories(onnxruntime_training_gpt2 PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${ONNXRUNTIME_ROOT} ${ORTTRAINING_ROOT} ${MPI_CXX_INCLUDE_DIRS} ${eigen_INCLUDE_DIRS} ${CXXOPTS} ${extra_includes} ${onnxruntime_graph_header} ${onnxruntime_exec_src_dir} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/onnx onnxruntime_training_runner)
|
|
|
|
target_link_libraries(onnxruntime_training_gpt2 PRIVATE onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_LIBS} ${onnxruntime_EXTERNAL_LIBRARIES})
|
|
set_target_properties(onnxruntime_training_gpt2 PROPERTIES FOLDER "ONNXRuntimeTest")
|