From 1f7709fc24a4f5a94b0525d0889ded4c782f469c Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 17 Oct 2024 15:13:48 -0700 Subject: [PATCH 1/8] Testing dependency download --- CMakeLists.txt | 4 +++- cmake/download_onnxruntime.cmake | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 cmake/download_onnxruntime.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b15fe7b..35fb474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,8 @@ if(NOT CMAKE_BUILD_TYPE) endif() set(TRITON_ONNXRUNTIME_DOCKER_BUILD OFF) +# Download onnxruntime +include(cmake/download_onnxruntime.cmake) if(TRITON_ONNXRUNTIME_LIB_PATHS STREQUAL "") set(TRITON_ONNXRUNTIME_DOCKER_BUILD ON) endif() @@ -138,7 +140,7 @@ endif() message(STATUS "Using Onnxruntime docker: ${TRITON_ONNXRUNTIME_DOCKER_BUILD}") if(NOT TRITON_ONNXRUNTIME_DOCKER_BUILD) - find_library(ONNXRUNTIME_LIBRARY NAMES onnxruntime PATHS ${TRITON_ONNXRUNTIME_LIB_PATHS}) + find_library(ONNXRUNTIME_LIBRARY NAMES onnxruntime PATHS ${TRITON_ONNXRUNTIME_LIB_PATHS} REQUIRED) if(${TRITON_ENABLE_ONNXRUNTIME_OPENVINO}) find_library(OV_LIBRARY NAMES openvino diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake new file mode 100644 index 0000000..3ee60b6 --- /dev/null +++ b/cmake/download_onnxruntime.cmake @@ -0,0 +1,32 @@ +if(WIN32) + + message(NOTICE "Downloading onnxruntime") + + # Define the download and extraction paths) + set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") + set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") + + # Download the file + file(DOWNLOAD $ENV{TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) + + # Check the download status + list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) + if(NOT DOWNLOAD_RESULT EQUAL 0) + message(SEND_ERROR "Failed to download ${ONNXRUNTIME_PACKAGE_URL}") + else() + message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) + + # Extract the downloaded file + file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) + + # Make the extracted directory searchable for CMake + list(APPEND CMAKE_PREFIX_PATH ${EXTRACT_DIR}) + + # Find a specific library in the extracted folder + # find_library(ONNXRUNTIME_LIBRARY onnxruntime NAMES onnxruntime.dll onnxruntime.so PATHS ${EXTRACT_DIR} PATH_SUFFIXES lib include NO_DEFAULT_PATH) + + set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) + + endif(NOT DOWNLOAD_RESULT EQUAL 0) + +endif(WIN32) \ No newline at end of file From 63a6f83b50ee3eeb877cbd3e2a02cfc9f3f1663d Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 17 Oct 2024 18:08:55 -0700 Subject: [PATCH 2/8] Change the configuration file --- cmake/download_onnxruntime.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index 3ee60b6..dd9da22 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -1,6 +1,6 @@ if(WIN32) - message(NOTICE "Downloading onnxruntime") + message(NOTICE "Downloading onnxruntime: $ENV{TRITON_ONNXRUNTIME_PACKAGE_URL}") # Define the download and extraction paths) set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") @@ -19,12 +19,7 @@ if(WIN32) # Extract the downloaded file file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) - # Make the extracted directory searchable for CMake - list(APPEND CMAKE_PREFIX_PATH ${EXTRACT_DIR}) - - # Find a specific library in the extracted folder - # find_library(ONNXRUNTIME_LIBRARY onnxruntime NAMES onnxruntime.dll onnxruntime.so PATHS ${EXTRACT_DIR} PATH_SUFFIXES lib include NO_DEFAULT_PATH) - + set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) endif(NOT DOWNLOAD_RESULT EQUAL 0) From bc8b479a4d37805c1f1fda2b092c427a82b99533 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 17 Oct 2024 19:07:51 -0700 Subject: [PATCH 3/8] Switch to argument vs variable --- cmake/download_onnxruntime.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index dd9da22..85b18e8 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -1,18 +1,18 @@ if(WIN32) - message(NOTICE "Downloading onnxruntime: $ENV{TRITON_ONNXRUNTIME_PACKAGE_URL}") + message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") # Define the download and extraction paths) set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") # Download the file - file(DOWNLOAD $ENV{TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) + file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) # Check the download status list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) if(NOT DOWNLOAD_RESULT EQUAL 0) - message(SEND_ERROR "Failed to download ${ONNXRUNTIME_PACKAGE_URL}") + message(SEND_ERROR "Failed to download: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") else() message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) From 2d85b9a056e4a4e9e97940ae1480c9560a5feeef Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 24 Oct 2024 07:28:51 -0700 Subject: [PATCH 4/8] Add logic to pull Onnx Runtime --- cmake/download_onnxruntime.cmake | 40 +++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index 85b18e8..50bafc0 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -1,27 +1,25 @@ -if(WIN32) +# Define the download and extraction paths) +set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") +set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") - message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") +if(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) + message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") + # Download the file + file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) - # Define the download and extraction paths) - set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") - set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") - # Download the file - file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) + # Check the download status + list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) + if(NOT DOWNLOAD_RESULT EQUAL 0) + message(NOTICE "Failed to download: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") + else() + message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) - # Check the download status - list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) - if(NOT DOWNLOAD_RESULT EQUAL 0) - message(SEND_ERROR "Failed to download: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") - else() - message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) + # Extract the downloaded file + file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) - # Extract the downloaded file - file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) + set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) + set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) - set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) - set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) - - endif(NOT DOWNLOAD_RESULT EQUAL 0) - -endif(WIN32) \ No newline at end of file + endif(NOT DOWNLOAD_RESULT EQUAL 0) +endif(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) \ No newline at end of file From 3a1fded40e2282a1b8e9792046f3b7a7bffe027e Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Thu, 24 Oct 2024 07:35:01 -0700 Subject: [PATCH 5/8] Formating configuration --- cmake/download_onnxruntime.cmake | 40 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index 50bafc0..394b4db 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -1,25 +1,29 @@ -# Define the download and extraction paths) -set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") -set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") - if(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) - message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") - # Download the file - file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) + # Define the download and extraction paths) + set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") + set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") + + message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") + + # Download the file + file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) + + # Check the download status + list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) + # Extract the downloaded file if the download was successful + if(NOT DOWNLOAD_RESULT EQUAL 0) + message(NOTICE "Failed to download: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") + else() + message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) - # Check the download status - list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) - if(NOT DOWNLOAD_RESULT EQUAL 0) - message(NOTICE "Failed to download: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") - else() - message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) + # Extract the downloaded file + file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) - # Extract the downloaded file - file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) + # Update CMakeLists.txt configuration references with new values + set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) + set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) - set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) - set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) + endif(NOT DOWNLOAD_RESULT EQUAL 0) - endif(NOT DOWNLOAD_RESULT EQUAL 0) endif(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) \ No newline at end of file From 0ac3238624f2f606a2649e0a0aa37a9481f60966 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Sat, 26 Oct 2024 09:56:38 -0700 Subject: [PATCH 6/8] Remove unused comments --- cmake/download_onnxruntime.cmake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index 394b4db..75fbef8 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -1,26 +1,22 @@ if(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) - # Define the download and extraction paths) + set(DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime.zip") set(EXTRACT_DIR "${CMAKE_BINARY_DIR}/_deps/downloads/onnxruntime") message(NOTICE "Downloading onnxruntime: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") - # Download the file file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) - # Check the download status + # file() STATUS returns a list with 2 elements list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) - # Extract the downloaded file if the download was successful if(NOT DOWNLOAD_RESULT EQUAL 0) message(NOTICE "Failed to download: ${TRITON_ONNXRUNTIME_PACKAGE_URL}") else() message(NOTICE "Download successful: ${DOWNLOAD_PATH}" ) - # Extract the downloaded file file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) - # Update CMakeLists.txt configuration references with new values set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) From 14bad5d9c1c325d123a0e841c06b9469e753592b Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Sat, 26 Oct 2024 10:12:02 -0700 Subject: [PATCH 7/8] Update comment --- cmake/download_onnxruntime.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index 75fbef8..b52914e 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -7,7 +7,7 @@ if(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) file(DOWNLOAD ${TRITON_ONNXRUNTIME_PACKAGE_URL} ${DOWNLOAD_PATH} SHOW_PROGRESS STATUS DOWNLOAD_STATUS) - # file() STATUS returns a list with 2 elements + # file(DOWNLOAD ... STATUS DOWNLOAD_STATUS) returns a list with 2 elements list(GET DOWNLOAD_STATUS 0 DOWNLOAD_RESULT) if(NOT DOWNLOAD_RESULT EQUAL 0) From 692499a1c7affd15613ec44c2ea63784f9ce59c8 Mon Sep 17 00:00:00 2001 From: Misha Chornyi Date: Tue, 29 Oct 2024 11:37:55 -0700 Subject: [PATCH 8/8] Adding varification snippet --- cmake/download_onnxruntime.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/download_onnxruntime.cmake b/cmake/download_onnxruntime.cmake index b52914e..0c09025 100644 --- a/cmake/download_onnxruntime.cmake +++ b/cmake/download_onnxruntime.cmake @@ -17,8 +17,14 @@ if(DEFINED TRITON_ONNXRUNTIME_PACKAGE_URL) file(ARCHIVE_EXTRACT INPUT ${DOWNLOAD_PATH} DESTINATION ${EXTRACT_DIR} VERBOSE ) - set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) - set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) + file(READ "${EXTRACT_DIR}/VERSION_NUMBER" DOWNLOADED_ONNXRUNTIME_VERSION) + if(${DOWNLOADED_ONNXRUNTIME_VERSION} VERSION_EQUAL ${TRITON_BUILD_ONNXRUNTIME_VERSION}) + message(NOTICE "Downloaded onnxruntime version: ${DOWNLOADED_ONNXRUNTIME_VERSION}") + set(TRITON_ONNXRUNTIME_INCLUDE_PATHS ${EXTRACT_DIR}/include) + set(TRITON_ONNXRUNTIME_LIB_PATHS ${EXTRACT_DIR}/lib) + else() + message(NOTICE "Downloaded onnxruntime version: ${DOWNLOADED_ONNXRUNTIME_VERSION} does not match the required version: ${TRITON_BUILD_ONNXRUNTIME_VERSION}") + endif() endif(NOT DOWNLOAD_RESULT EQUAL 0)