From 647be61b7b791fc2a60a50511741914bb401394d Mon Sep 17 00:00:00 2001 From: Cristhian Date: Mon, 7 Sep 2026 14:33:33 -0300 Subject: [PATCH] fix ONNX Runtime install layout so CMake can find it The release tarball ships its CMake package files under lib/, but onnxruntimeTargets.cmake resolves the library as /lib64. Ubuntu is multiarch, so CMake does not search lib64 for packages and ld.so does not search /usr/local/lib64 at all, leaving find_package(onnxruntime) failing on a stock install. Keep the libraries in lib64, move only the package files to lib/cmake, and add lib64 to the linker path. --- scripts/install_linux_x64.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/install_linux_x64.sh b/scripts/install_linux_x64.sh index cd10f5d..ff05d0a 100755 --- a/scripts/install_linux_x64.sh +++ b/scripts/install_linux_x64.sh @@ -35,7 +35,7 @@ else fi # --- ONNX Runtime (C++ GPU, installs to /usr/local) --- -if [ -f /usr/local/lib64/libonnxruntime.so ] && [ -d /usr/local/include/onnxruntime ]; then +if [ -f /usr/local/lib64/libonnxruntime.so ] && [ -d /usr/local/lib/cmake/onnxruntime ]; then echo ">>> ONNX Runtime already installed — skipping." else echo ">>> Downloading ONNX Runtime ${ORT_VERSION} GPU..." @@ -49,6 +49,15 @@ else sudo cp -r "${TMP_DIR}/onnxruntime-linux-x64-gpu-${ORT_VERSION}/include/"* /usr/local/include/onnxruntime/ sudo mkdir -p /usr/local/lib64 sudo cp -r "${TMP_DIR}/onnxruntime-linux-x64-gpu-${ORT_VERSION}/lib/"* /usr/local/lib64/ + # onnxruntimeTargets.cmake resolves the library as /lib64, but Ubuntu + # is multiarch: CMake does not search lib64 for packages and ld.so does not + # search /usr/local/lib64 at all. Move only the package files to lib/cmake + # and put lib64 on the linker path. + sudo mkdir -p /usr/local/lib/cmake + sudo rm -rf /usr/local/lib/cmake/onnxruntime + sudo mv /usr/local/lib64/cmake/onnxruntime /usr/local/lib/cmake/ + sudo rmdir /usr/local/lib64/cmake + echo /usr/local/lib64 | sudo tee /etc/ld.so.conf.d/onnxruntime.conf > /dev/null sudo ldconfig fi