From 2be37f7313bec8f4ce732d228c062e7337c5a2ba Mon Sep 17 00:00:00 2001
From: Misha Chornyi <99709299+mc-nv@users.noreply.github.com>
Date: Tue, 7 Jan 2025 11:21:53 -0800
Subject: [PATCH] Upadate default branch post 24.12 (#290)

* Update README and versions for 2.53.0 / 24.12 (#288)

* Update 'gen_ort_dockerfile.py' fil to meet changes in ONNX Runtime 1.20.x

* remove psutils

* Update reformating

* restore description

* Update OpenVINO to 2024.5 (#287)

* Update 'gen_ort_dockerfile.py' fil to meet changes in ONNX Runtime 1.20.x

* remove psutils

* Add OpenVINO version

* Fix pre-commit issues

* Extract archive in different location (#289)

* Extract archive in different location

* Revert "Extract archive in different location"

This reverts commit e57256a07c1c39afec0e9355e8433ea01dcbd569.

* Update installation instructions

* Reapply "Extract archive in different location"

This reverts commit 59e24e48c6306990f8a59326164f3acef842b3c4.
---
 CMakeLists.txt                   |  2 +-
 cmake/download_onnxruntime.cmake |  2 +-
 tools/gen_ort_dockerfile.py      | 25 ++++++++-----------------
 3 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94d396d..3e450fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -418,7 +418,7 @@ install(
 # that tar file. We copy over the libraries and other requirements
 # prior to running this build and therefore these set of install
 # commands are not needed.
-if(TRITON_ONNXRUNTIME_DOCKER_BUILD)
+if(TRITON_ONNXRUNTIME_DOCKER_BUILD OR DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL)
   install(
     DIRECTORY
       ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime/
diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake
index 0c09025..6401c2b 100644
--- a/cmake/download_onnxruntime.cmake
+++ b/cmake/download_onnxruntime.cmake
@@ -1,7 +1,7 @@
 if(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL)
 
   set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip")
-  set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime")
+  set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/onnxruntime")
 
   message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}")
 
diff --git a/tools/gen_ort_dockerfile.py b/tools/gen_ort_dockerfile.py
index ef5c0b3..82f9554 100755
--- a/tools/gen_ort_dockerfile.py
+++ b/tools/gen_ort_dockerfile.py
@@ -56,6 +56,10 @@
         "2024.4",  # OpenVINO short version
         "2024.4.0.16579.c3152d32c9c",  # OpenVINO version with build number
     ),
+    "2024.5.0": (
+        "2024.5",  # OpenVINO short version
+        "2024.5.0.17288.7975fa5da0c",  # OpenVINO version with build number
+    ),
 }
 
 
@@ -157,16 +161,6 @@ def dockerfile_for_linux(output_file):
     && apt-get install -y --no-install-recommends cmake=3.28.3* cmake-data=3.28.3* \\
     && cmake --version
 
-"""
-    if FLAGS.enable_gpu:
-        df += """
-# Allow configure to pick up cuDNN where it expects it.
-# (Note: $CUDNN_VERSION is defined by base image)
-RUN _CUDNN_VERSION=$(echo $CUDNN_VERSION | cut -d. -f1-2) && \
-    mkdir -p /usr/local/cudnn-$_CUDNN_VERSION/cuda/include && \
-    ln -s /usr/include/cudnn.h /usr/local/cudnn-$_CUDNN_VERSION/cuda/include/cudnn.h && \
-    mkdir -p /usr/local/cudnn-$_CUDNN_VERSION/cuda/lib64 && \
-    ln -s /etc/alternatives/libcudnn_so /usr/local/cudnn-$_CUDNN_VERSION/cuda/lib64/libcudnn.so
 """
 
     if FLAGS.ort_openvino is not None:
@@ -395,7 +389,7 @@ def dockerfile_for_linux(output_file):
 """
     df += """
 RUN cd /opt/onnxruntime/lib && \
-    for i in `find . -mindepth 1 -maxdepth 1 -type f -name '*\.so*'`; do \
+    for i in `find . -mindepth 1 -maxdepth 1 -type f -name '*\\.so*'`; do \
         patchelf --set-rpath '$ORIGIN' $i; \
     done
 
@@ -476,7 +470,7 @@ def dockerfile_for_windows(output_file):
 
     df += """
 WORKDIR /workspace/onnxruntime
-ARG VS_DEVCMD_BAT="\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
+ARG VS_DEVCMD_BAT="\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat"
 RUN powershell Set-Content 'build.bat' -value 'call %VS_DEVCMD_BAT%',(Get-Content 'build.bat')
 RUN build.bat --cmake_generator "Visual Studio 17 2022" --config Release --cmake_extra_defines "CMAKE_CUDA_ARCHITECTURES=75;80;86;90" --skip_submodule_sync --parallel --build_shared_lib --compile_no_warning_as_error --skip_tests --update --build --build_dir /workspace/build {}
 """.format(
@@ -559,12 +553,8 @@ def preprocess_gpu_flags():
             FLAGS.tensorrt_home = "/tensorrt"
     else:
         if "CUDNN_VERSION" in os.environ:
-            version = None
-            m = re.match(r"([0-9]\.[0-9])\.[0-9]\.[0-9]", os.environ["CUDNN_VERSION"])
-            if m:
-                version = m.group(1)
             if FLAGS.cudnn_home is None:
-                FLAGS.cudnn_home = "/usr/local/cudnn-{}/cuda".format(version)
+                FLAGS.cudnn_home = "/usr"
 
         if FLAGS.cuda_home is None:
             FLAGS.cuda_home = "/usr/local/cuda"
@@ -611,6 +601,7 @@ def preprocess_gpu_flags():
         default=None,
         help='Target for build, can be "linux", "windows", "rhel", or "igpu". If not specified, build targets the current platform.',
     )
+
     parser.add_argument(
         "--cuda-version", type=str, required=False, help="Version for CUDA."
     )