From ae2395cb5654775d1c3492c2fc035f1087f38560 Mon Sep 17 00:00:00 2001 From: RandySheriffH <48490400+RandySheriffH@users.noreply.github.com> Date: Tue, 23 May 2023 10:11:47 -0700 Subject: [PATCH] Cherry-pick the fix to build rel-1.15 python package for AzureEP (#16044) Cherry-pick the fix to build python package for AzureEP. Co-authored-by: Randy Shuai --- cmake/external/triton.cmake | 6 +++--- cmake/onnxruntime_framework.cmake | 2 +- setup.py | 18 +----------------- .../linux/build_linux_arm64_python_package.sh | 3 +-- .../x64/python/cpu/scripts/install_centos.sh | 13 ++++++++++++- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/cmake/external/triton.cmake b/cmake/external/triton.cmake index 9f9da0d8a6..41da407adf 100644 --- a/cmake/external/triton.cmake +++ b/cmake/external/triton.cmake @@ -75,7 +75,9 @@ else() PREFIX rapidjson SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/rapidjson-src BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/rapidjson-build - CMAKE_ARGS -DRAPIDJSON_BUILD_TESTS=OFF -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF) + CMAKE_ARGS -DRAPIDJSON_BUILD_TESTS=OFF -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF + INSTALL_COMMAND "" + UPDATE_COMMAND "") ExternalProject_Get_Property(rapidjson source_dir) set(RAPIDJSON_INCLUDE_DIR ${source_dir}/include) @@ -91,8 +93,6 @@ else() INSTALL_COMMAND "" UPDATE_COMMAND "") - add_dependencies(triton rapidjson) - endif() #if (WIN32) ExternalProject_Get_Property(triton SOURCE_DIR) diff --git a/cmake/onnxruntime_framework.cmake b/cmake/onnxruntime_framework.cmake index fcbae6ad32..1254cd16f2 100644 --- a/cmake/onnxruntime_framework.cmake +++ b/cmake/onnxruntime_framework.cmake @@ -52,7 +52,7 @@ if (onnxruntime_USE_AZURE) find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) - target_link_libraries(onnxruntime_framework PRIVATE httpclient_static curl OpenSSL::Crypto OpenSSL::SSL) + target_link_libraries(onnxruntime_framework PRIVATE httpclient_static curl ZLIB::ZLIB OpenSSL::Crypto OpenSSL::SSL) endif() #if (WIN32) diff --git a/setup.py b/setup.py index adfd306287..67b365d2dc 100644 --- a/setup.py +++ b/setup.py @@ -176,21 +176,6 @@ try: f.write(" import os\n") f.write(' os.environ["ORT_TENSORRT_UNAVAILABLE"] = "1"\n') - def _rewrite_ld_preload_azure(self): - with open("onnxruntime/capi/_ld_preload.py", "a") as f: - f.write("import os\n") - f.write("from ctypes import CDLL, RTLD_GLOBAL, util\n") - f.write("def LoadLib(lib_name):\n") - f.write(" lib_path = util.find_library(lib_name)\n") - f.write(" if lib_path: _ = CDLL(lib_path, mode=RTLD_GLOBAL)\n") - f.write(" else: _ = CDLL(lib_name, mode=RTLD_GLOBAL)\n") - f.write('for lib_name in ["RE2", "ZLIB1"]:\n') - f.write(" try:\n") - f.write(" LoadLib(lib_name)\n") - f.write(" except OSError:\n") - f.write(' print("Could not load ort azure-ep dependency: " + lib_name)\n') - f.write(' os.environ["ORT_" + lib_name + "_UNAVAILABLE"] = "1"\n') - def run(self): if is_manylinux: source = "onnxruntime/capi/onnxruntime_pybind11_state.so" @@ -315,8 +300,7 @@ try: self._rewrite_ld_preload(to_preload_cann) else: - if package_name == "onnxruntime-azure": - self._rewrite_ld_preload_azure() + pass _bdist_wheel.run(self) if is_manylinux and not disable_auditwheel_repair and not is_openvino: diff --git a/tools/ci_build/github/linux/build_linux_arm64_python_package.sh b/tools/ci_build/github/linux/build_linux_arm64_python_package.sh index 88ac111fd8..5bb7548aad 100755 --- a/tools/ci_build/github/linux/build_linux_arm64_python_package.sh +++ b/tools/ci_build/github/linux/build_linux_arm64_python_package.sh @@ -50,8 +50,7 @@ elif [ "$BUILD_DEVICE" == "AZURE" ]; then # for ubuntu apt-get install -y libipc-system-simple-perl python3 libssl-dev else - # for redhat - yum install -y perl-IPC-Cmd python3 openssl-devel + export PATH=/opt/python/cp38-cp38/bin:$PATH fi fi diff --git a/tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/install_centos.sh b/tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/install_centos.sh index db4b617744..58c526a114 100755 --- a/tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/install_centos.sh +++ b/tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/install_centos.sh @@ -4,4 +4,15 @@ set -e os_major_version=$(cat /etc/redhat-release | tr -dc '0-9.'|cut -d \. -f1) echo "installing for os major version : $os_major_version" -yum install -y which gdb redhat-lsb-core expat-devel tar unzip zlib-devel make libunwind bzip2 bzip2-devel +yum install -y which gdb redhat-lsb-core expat-devel tar unzip zlib-devel make libunwind bzip2 bzip2-devel perl-IPC-Cmd openssl-devel wget +# export PATH=/opt/python/cp38-cp38/bin:$PATH + +echo "installing rapidjson for AzureEP" +wget https://github.com/Tencent/rapidjson/archive/refs/tags/v1.1.0.tar.gz +tar zxvf v1.1.0.tar.gz +cd rapidjson-1.1.0 +mkdir build +cd build +cmake .. +cmake --install . +cd ../.. \ No newline at end of file