From 728e332c25edb0098f0da1f2680abf2b242a343e Mon Sep 17 00:00:00 2001 From: Baiju Meswani Date: Mon, 5 Aug 2024 06:29:02 +0000 Subject: [PATCH] Use soname --- src/models/onnxruntime_api.h | 27 +-------------------------- src/python/py/_dll_directory.py | 3 --- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/models/onnxruntime_api.h b/src/models/onnxruntime_api.h index 2b7f3371e..e89613b66 100644 --- a/src/models/onnxruntime_api.h +++ b/src/models/onnxruntime_api.h @@ -213,32 +213,7 @@ inline void InitApi() { #if !defined(__ANDROID__) if (ort_lib_handle == nullptr) { - const std::array target_libraries = { - std::string("libonnxruntime.so"), - std::string("libonnxruntime.so.1.18.0"), - std::string("libonnxruntime.so.1.19.0"), - std::string("libonnxruntime.so.1.20.0")}; - - // Search parent directory - std::string current_module_dir = GetCurrentModuleDir(); - for (const std::string& lib_name : target_libraries) { - std::string pip_path{current_module_dir + "/" + lib_name}; - ort_lib_handle = LoadDynamicLibraryIfExists(pip_path); - if (ort_lib_handle != nullptr) { - break; - } - } - - if (ort_lib_handle == nullptr) { - // Search for pip installation - for (const std::string& lib_name : target_libraries) { - std::string pip_path{current_module_dir + "/../onnxruntime/capi/" + lib_name}; - ort_lib_handle = LoadDynamicLibraryIfExists(pip_path); - if (ort_lib_handle != nullptr) { - break; - } - } - } + ort_lib_handle = LoadDynamicLibraryIfExists("libonnxruntime.so.1"); } #endif diff --git a/src/python/py/_dll_directory.py b/src/python/py/_dll_directory.py index d82c6a7c4..d8fe005cd 100644 --- a/src/python/py/_dll_directory.py +++ b/src/python/py/_dll_directory.py @@ -44,9 +44,6 @@ def add_onnxruntime_dependency(): _ = ctypes.CDLL(ort_lib_path[0]) - providers_lib_path = glob.glob(os.path.join(ort_package_path, "capi", "libonnxruntime_providers_*.so")) - _ = [ctypes.CDLL(providers_lib_path[i]) for i in range(len(providers_lib_path))] - def add_cuda_dependency(): """Add the CUDA DLL directory to the DLL search path.