diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index 18e00f1470..a63afa22e2 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -71,13 +71,6 @@ CopyToOutputDirectory="Never" Visible="false" /> - SetSessionGraphOptimizationLevel(session_options, ORT_ENABLE_BASIC); // Optionally add more execution providers via session_options - // E.g. for CUDA include cuda_provider_factory.h and uncomment the following line: + // E.g. for CUDA uncomment the following line: // OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, 0); //************************************************************************* diff --git a/include/onnxruntime/core/session/onnxruntime_c_api.h b/include/onnxruntime/core/session/onnxruntime_c_api.h index 8a547cd6f5..7b2be8b88d 100644 --- a/include/onnxruntime/core/session/onnxruntime_c_api.h +++ b/include/onnxruntime/core/session/onnxruntime_c_api.h @@ -1502,6 +1502,14 @@ struct OrtCustomOp { OrtCustomOpInputOutputCharacteristic(ORT_API_CALL* GetOutputCharacteristic)(_In_ const struct OrtCustomOp* op, _In_ size_t index); }; +/* + * This is the old way to add the CUDA provider to the session, please use SessionOptionsAppendExecutionProvider_CUDA above to access the latest functionality + * This function always exists, but will only succeed if Onnxruntime was built with CUDA support and the CUDA provider shared library exists + * + * \param device_id cuda device id, starts from zero. +*/ +ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, int device_id); + #ifdef __cplusplus } #endif diff --git a/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c b/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c index b2218e265f..b78f4fd8ad 100644 --- a/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c +++ b/java/src/main/native/ai_onnxruntime_OrtSession_SessionOptions.c @@ -15,7 +15,6 @@ // Providers #include "onnxruntime/core/providers/cpu/cpu_provider_factory.h" -#include "onnxruntime/core/providers/cuda/cuda_provider_factory.h" #include "onnxruntime/core/providers/dnnl/dnnl_provider_factory.h" #include "onnxruntime/core/providers/nnapi/nnapi_provider_factory.h" #include "onnxruntime/core/providers/nuphar/nuphar_provider_factory.h" diff --git a/include/onnxruntime/core/providers/cuda/cuda_provider_factory.h b/onnxruntime/core/providers/cuda/cuda_provider_factory.h similarity index 91% rename from include/onnxruntime/core/providers/cuda/cuda_provider_factory.h rename to onnxruntime/core/providers/cuda/cuda_provider_factory.h index 6fcf582684..40ec4d5458 100644 --- a/include/onnxruntime/core/providers/cuda/cuda_provider_factory.h +++ b/onnxruntime/core/providers/cuda/cuda_provider_factory.h @@ -2,8 +2,6 @@ // Licensed under the MIT License. #include "onnxruntime_c_api.h" - -#ifdef __cplusplus #include "core/framework/provider_options.h" namespace onnxruntime { @@ -18,8 +16,6 @@ namespace cuda { class INcclService; } -} // namespace onnxruntime - struct ProviderInfo_CUDA { virtual OrtStatus* SetCurrentGpuDeviceId(_In_ int device_id) = 0; virtual OrtStatus* GetCurrentGpuDeviceId(_In_ int* device_id) = 0; @@ -48,14 +44,4 @@ struct ProviderInfo_CUDA { virtual std::shared_ptr CreateCudaAllocator(int16_t device_id, size_t gpu_mem_limit, onnxruntime::ArenaExtendStrategy arena_extend_strategy, onnxruntime::CUDAExecutionProviderExternalAllocatorInfo& external_allocator_info, OrtArenaCfg* default_memory_arena_cfg) = 0; }; -extern "C" { -#endif - -/** - * \param device_id cuda device id, starts from zero. - */ -ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_CUDA, _In_ OrtSessionOptions* options, int device_id); - -#ifdef __cplusplus -} -#endif +} // namespace onnxruntime diff --git a/onnxruntime/core/session/onnxruntime_c_api.cc b/onnxruntime/core/session/onnxruntime_c_api.cc index ad743598e2..5c3b464f33 100644 --- a/onnxruntime/core/session/onnxruntime_c_api.cc +++ b/onnxruntime/core/session/onnxruntime_c_api.cc @@ -40,10 +40,6 @@ #include "ortcustomops.h" #endif -#ifdef USE_CUDA -#include "core/providers/cuda/cuda_provider_factory.h" -#endif - using namespace onnxruntime::logging; using onnxruntime::BFloat16; using onnxruntime::DataTypeImpl; diff --git a/onnxruntime/python/tools/tensorrt/perf/mem_test/main.cpp b/onnxruntime/python/tools/tensorrt/perf/mem_test/main.cpp index 0d14f6fb75..a3fd958941 100644 --- a/onnxruntime/python/tools/tensorrt/perf/mem_test/main.cpp +++ b/onnxruntime/python/tools/tensorrt/perf/mem_test/main.cpp @@ -160,9 +160,7 @@ void ort_trt_run_with_default_options() { Ort::SessionOptions session_options; session_options.SetIntraOpNumThreads(1); - // If onnxruntime.dll is built with CUDA enabled, we can uncomment out this line to use CUDA for this - // session (we also need to include cuda_provider_factory.h above which defines it) - // #include "cuda_provider_factory.h" + // If onnxruntime.dll is built with CUDA enabled, we can uncomment out this line to use CUDA for this session // OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 1); OrtSessionOptionsAppendExecutionProvider_Tensorrt(session_options, 0); diff --git a/onnxruntime/test/shared_lib/test_model_loading.cc b/onnxruntime/test/shared_lib/test_model_loading.cc index 5db2b50371..9457cf9029 100644 --- a/onnxruntime/test/shared_lib/test_model_loading.cc +++ b/onnxruntime/test/shared_lib/test_model_loading.cc @@ -4,9 +4,6 @@ #include "core/session/onnxruntime_cxx_api.h" #include "onnxruntime_session_options_config_keys.h" #include "test/util/include/asserts.h" -#ifdef USE_CUDA -#include "core/providers/cuda/cuda_provider_factory.h" -#endif #include #include "test_fixture.h" #include "file_util.h" diff --git a/onnxruntime/test/util/include/providers.h b/onnxruntime/test/util/include/providers.h index 2f6a62b9a7..de74c8f796 100644 --- a/onnxruntime/test/util/include/providers.h +++ b/onnxruntime/test/util/include/providers.h @@ -4,9 +4,6 @@ #pragma once #include "core/providers/cpu/cpu_provider_factory.h" -#ifdef USE_CUDA -#include "core/providers/cuda/cuda_provider_factory.h" -#endif #ifdef USE_DNNL #include "core/providers/dnnl/dnnl_provider_factory.h" #endif diff --git a/tools/ci_build/gen_def.py b/tools/ci_build/gen_def.py index 61f5bb491d..7e7e6651a7 100755 --- a/tools/ci_build/gen_def.py +++ b/tools/ci_build/gen_def.py @@ -64,7 +64,7 @@ with open(args.output_source, 'w') as file: # WinML adapter should not be exported in platforms other than Windows. # Exporting OrtGetWinMLAdapter is exported without issues using .def file when compiling for Windows # so it isn't necessary to include it in generated_source.c - if c != "winml": + if c != "winml" and c != "cuda": file.write("#include \n" % (c, c)) file.write("void* GetFunctionEntryByName(const char* name){\n") for symbol in symbols: diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml index 46fb2ea719..77c7f06d4e 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-artifacts-package-and-publish-steps-windows.yml @@ -43,7 +43,6 @@ steps: copy $(Build.SourcesDirectory)\include\onnxruntime\core\session\onnxruntime_*.h $(Build.BinariesDirectory)\${{parameters.artifactName}}\include copy $(Build.SourcesDirectory)\include\onnxruntime\core\framework\provider_options.h $(Build.BinariesDirectory)\${{parameters.artifactName}}\include copy $(Build.SourcesDirectory)\include\onnxruntime\core\providers\cpu\cpu_provider_factory.h $(Build.BinariesDirectory)\${{parameters.artifactName}}\include - copy $(Build.SourcesDirectory)\include\onnxruntime\core\providers\cuda\cuda_provider_factory.h $(Build.BinariesDirectory)\${{parameters.artifactName}}\include REM copy the README, licence and TPN copy $(Build.SourcesDirectory)\README.md $(Build.BinariesDirectory)\${{parameters.artifactName}}\README.md diff --git a/tools/ci_build/github/linux/copy_strip_binary.sh b/tools/ci_build/github/linux/copy_strip_binary.sh index 634697478a..f64e975a48 100755 --- a/tools/ci_build/github/linux/copy_strip_binary.sh +++ b/tools/ci_build/github/linux/copy_strip_binary.sh @@ -43,7 +43,6 @@ cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_c_api.h $BINARY_DIR cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_cxx_api.h $BINARY_DIR/$ARTIFACT_NAME/include cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_cxx_inline.h $BINARY_DIR/$ARTIFACT_NAME/include cp $SOURCE_DIR/include/onnxruntime/core/providers/cpu/cpu_provider_factory.h $BINARY_DIR/$ARTIFACT_NAME/include -cp $SOURCE_DIR/include/onnxruntime/core/providers/cuda/cuda_provider_factory.h $BINARY_DIR/$ARTIFACT_NAME/include cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h $BINARY_DIR/$ARTIFACT_NAME/include cp $SOURCE_DIR/include/onnxruntime/core/session/onnxruntime_run_options_config_keys.h $BINARY_DIR/$ARTIFACT_NAME/include cp $SOURCE_DIR/include/onnxruntime/core/framework/provider_options.h $BINARY_DIR/$ARTIFACT_NAME/include diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 35a297ab0f..aafeb1f78a 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -184,7 +184,6 @@ def generate_files(list, args): is_dml_package = args.package_name == 'Microsoft.ML.OnnxRuntime.DirectML' is_windowsai_package = args.package_name == 'Microsoft.AI.MachineLearning' - includes_cuda = is_cuda_gpu_package or is_cpu_package # Why does the CPU package ship the cuda provider headers? includes_winml = is_windowsai_package includes_directml = (is_dml_package or is_windowsai_package) and not args.is_store_build and ( args.target_architecture == 'x64' or args.target_architecture == 'x86') @@ -246,12 +245,6 @@ def generate_files(list, args): 'include\\onnxruntime\\core\\providers\\cpu\\cpu_provider_factory.h') + '" target="build\\native\\include" />') - if includes_cuda: - files_list.append('') - if args.execution_provider == 'openvino': files_list.append('