From c80e36c6823191e1e86eaa1f660afe9e80bed49d Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Thu, 15 Aug 2024 17:23:51 +0200 Subject: [PATCH 01/19] OnnxRuntime build on AMD GPU's --- onnxruntime.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index ada2edfd23..10a77e7dec 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -27,7 +27,18 @@ cmake "$SOURCEDIR/cmake" -Donnxruntime_BUILD_UNIT_TESTS=OFF \ -Donnxruntime_PREFER_SYSTEM_LIB=ON \ -Donnxruntime_BUILD_SHARED_LIB=ON \ + -Donnxruntime_USE_ROCM=ON \ + -Donnxruntime_ROCM_HOME=/opt/rocm \ + -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ + -D__HIP_PLATFORM_AMD__=1 \ + -DCMAKE_HIP_ARCHITECTURES=gfx906,gfx908 \ + -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ + -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ + -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ + -Donnxruntime_ENABLE_TRAINING=OFF \ -DProtobuf_USE_STATIC_LIBS=ON \ + -Donnxruntime_DISABLE_RTTI=OFF \ + -DMSVC=OFF \ ${PROTOBUF_ROOT:+-DProtobuf_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf.a} \ ${PROTOBUF_ROOT:+-DProtobuf_LITE_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf-lite.a} \ ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_LIBRARY=$PROTOBUF_ROOT/lib/libprotoc.a} \ @@ -35,8 +46,8 @@ cmake "$SOURCEDIR/cmake" ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_EXECUTABLE=$PROTOBUF_ROOT/bin/protoc} \ ${RE2_ROOT:+-DRE2_INCLUDE_DIR=${RE2_ROOT}/include} \ ${BOOST_ROOT:+-DBOOST_INCLUDE_DIR=${BOOST_ROOT}/include} \ - -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-error=unused-but-set-variable" \ - -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-error=unused-but-set-variable" + -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning" \ + -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning" cmake --build . -- ${JOBS:+-j$JOBS} install From 23c3e5f5916c167995d098fea53b50cbc5c26576 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Wed, 4 Sep 2024 18:37:50 +0200 Subject: [PATCH 02/19] Modifying recipe for build on Nvidia GPU's (still needs testing) --- onnxruntime.sh | 64 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 10a77e7dec..d176fb362b 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -19,7 +19,60 @@ prepend_path: mkdir -p $INSTALLROOT +ORT_BUILD_FLAGS="" +case $ARCHITECTURE in + osx_*) + if [[ $ARCHITECTURE == *_x86-64 ]]; then + echo "Installing ONNXRuntime for MacOS (CPU version)" + else + echo "Installing ONNXRuntime for MacOS (Metal backend)" + fi + ;; + *) + if command -v rocminfo >/dev/null 2>&1; then + echo "Installing ONNXRuntime for ROCm" + ORT_BUILD_FLAGS="\ + -Donnxruntime_USE_ROCM=ON \ + -Donnxruntime_ROCM_HOME=/opt/rocm \ + -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ + -D__HIP_PLATFORM_AMD__=1 \ + -DCMAKE_HIP_ARCHITECTURES=gfx906,gfx908 \ + -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ + -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ + -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ + -Donnxruntime_ENABLE_TRAINING=OFF \ + -Donnxruntime_DISABLE_RTTI=OFF \ + -DMSVC=OFF \ + " + elif command -v nvcc >/dev/null 2>&1; then + CUDA_VERSION=$(nvcc --version | grep "release" | awk '{print $NF}' | cut -d. -f1) + if [[ "$CUDA_VERSION" == "V11" ]]; then + echo "Installing ONNXRuntime for CUDA 11.x" + ORT_BUILD_FLAGS="\ + -Donnxruntime_USE_CUDA=ON \ + -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ + -Donnxruntime_CUDA_USE_TENSORRT=ON \ + " + elif [[ "$CUDA_VERSION" == "V12" ]]; then + echo "Installing ONNXRuntime for CUDA 12.x" + ORT_BUILD_FLAGS="\ + -Donnxruntime_USE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT \ + -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ + -Donnxruntime_CUDA_USE_TENSORRT=ON \ + " + else + echo "CUDA version is not 11.x or 12.x, installing ONNXRuntime basic CPU version" + ORT_BUILD_FLAGS="" + fi + else + echo "Installing ONNXRuntime basic CPU version" + ORT_BUILD_FLAGS="" + fi + ;; +esac + cmake "$SOURCEDIR/cmake" \ + "$ORT_BUILD_FLAGS" \ -DCMAKE_INSTALL_PREFIX=$INSTALLROOT \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_LIBDIR=lib \ @@ -27,18 +80,7 @@ cmake "$SOURCEDIR/cmake" -Donnxruntime_BUILD_UNIT_TESTS=OFF \ -Donnxruntime_PREFER_SYSTEM_LIB=ON \ -Donnxruntime_BUILD_SHARED_LIB=ON \ - -Donnxruntime_USE_ROCM=ON \ - -Donnxruntime_ROCM_HOME=/opt/rocm \ - -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ - -D__HIP_PLATFORM_AMD__=1 \ - -DCMAKE_HIP_ARCHITECTURES=gfx906,gfx908 \ - -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ - -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ - -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ - -Donnxruntime_ENABLE_TRAINING=OFF \ -DProtobuf_USE_STATIC_LIBS=ON \ - -Donnxruntime_DISABLE_RTTI=OFF \ - -DMSVC=OFF \ ${PROTOBUF_ROOT:+-DProtobuf_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf.a} \ ${PROTOBUF_ROOT:+-DProtobuf_LITE_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf-lite.a} \ ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_LIBRARY=$PROTOBUF_ROOT/lib/libprotoc.a} \ From 78fcf074b04092a233c689c203f2f579eeee212e Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Tue, 17 Sep 2024 13:09:24 +0200 Subject: [PATCH 03/19] Updating ONNX build flags --- onnxruntime.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index d176fb362b..c3e709e9b0 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -1,6 +1,6 @@ package: ONNXRuntime version: "%(tag_basename)s" -tag: v1.18.0 +tag: v1.19.0 source: https://github.com/microsoft/onnxruntime requires: - protobuf @@ -33,6 +33,7 @@ case $ARCHITECTURE in echo "Installing ONNXRuntime for ROCm" ORT_BUILD_FLAGS="\ -Donnxruntime_USE_ROCM=ON \ + -Donnxruntime_USE_MIGRAPHX=ON \ -Donnxruntime_ROCM_HOME=/opt/rocm \ -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ -D__HIP_PLATFORM_AMD__=1 \ @@ -48,15 +49,15 @@ case $ARCHITECTURE in CUDA_VERSION=$(nvcc --version | grep "release" | awk '{print $NF}' | cut -d. -f1) if [[ "$CUDA_VERSION" == "V11" ]]; then echo "Installing ONNXRuntime for CUDA 11.x" - ORT_BUILD_FLAGS="\ - -Donnxruntime_USE_CUDA=ON \ + ORT_BUILD_FLAGS=" -Donnxruntime_USE_CUDA=ON \ + -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT \ -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ -Donnxruntime_CUDA_USE_TENSORRT=ON \ " elif [[ "$CUDA_VERSION" == "V12" ]]; then echo "Installing ONNXRuntime for CUDA 12.x" - ORT_BUILD_FLAGS="\ - -Donnxruntime_USE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT \ + ORT_BUILD_FLAGS=" -Donnxruntime_USE_CUDA=ON \ + -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT \ -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ -Donnxruntime_CUDA_USE_TENSORRT=ON \ " @@ -72,7 +73,7 @@ case $ARCHITECTURE in esac cmake "$SOURCEDIR/cmake" \ - "$ORT_BUILD_FLAGS" \ + $ORT_BUILD_FLAGS \ -DCMAKE_INSTALL_PREFIX=$INSTALLROOT \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_LIBDIR=lib \ From 73b54ce7e4f8cf6adc9677c68faaabda68d4f338 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Fri, 27 Sep 2024 10:53:37 +0200 Subject: [PATCH 04/19] Updating version to 1.19.0 --- onnxruntime.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 6909ea78f7..fa29e8e4ce 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -1,10 +1,6 @@ package: ONNXRuntime version: "%(tag_basename)s" -<<<<<<< HEAD tag: v1.19.0 -======= -tag: v1.18.1 ->>>>>>> master source: https://github.com/microsoft/onnxruntime requires: - protobuf From 5e42e469e858fee076b88972374e9491c56662a2 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Thu, 3 Oct 2024 13:48:17 +0200 Subject: [PATCH 05/19] Adding automatic checks for migraphx, changing build cmake flags and adding env-variables for GPU enabling during code execution. For al9_gpu container and simultaneous CUDA & ROCm build, this requires https://github.com/ChSonnabend/onnxruntime/commit/6ffc40c3357ab13c83b65447404594d1f53e34db --- onnxruntime.sh | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index fa29e8e4ce..6d16dc4e5c 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -30,10 +30,15 @@ case $ARCHITECTURE in ;; *) if command -v rocminfo >/dev/null 2>&1; then - echo "Installing ONNXRuntime for ROCm" - ORT_BUILD_FLAGS="\ + echo "Enabling ONNXRuntime build for ROCm" + export ORT_ROCM_BUILD=1 + if command -v find /opt/rocm* -name "libmigraphx*" >/dev/null 2>&1; then + echo " - ROCm build with MIGraphX" + export ORT_MIGRAPHX_BUILD=1 + ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} -Donnxruntime_USE_MIGRAPHX=ON" + fi + ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} \ -Donnxruntime_USE_ROCM=ON \ - -Donnxruntime_USE_MIGRAPHX=ON \ -Donnxruntime_ROCM_HOME=/opt/rocm \ -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ -D__HIP_PLATFORM_AMD__=1 \ @@ -41,33 +46,25 @@ case $ARCHITECTURE in -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ - -Donnxruntime_ENABLE_TRAINING=OFF \ -Donnxruntime_DISABLE_RTTI=OFF \ + -Donnxruntime_ENABLE_TRAINING=OFF \ -DMSVC=OFF \ " elif command -v nvcc >/dev/null 2>&1; then - CUDA_VERSION=$(nvcc --version | grep "release" | awk '{print $NF}' | cut -d. -f1) - if [[ "$CUDA_VERSION" == "V11" ]]; then - echo "Installing ONNXRuntime for CUDA 11.x" - ORT_BUILD_FLAGS=" -Donnxruntime_USE_CUDA=ON \ - -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT \ - -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ - -Donnxruntime_CUDA_USE_TENSORRT=ON \ - " - elif [[ "$CUDA_VERSION" == "V12" ]]; then - echo "Installing ONNXRuntime for CUDA 12.x" - ORT_BUILD_FLAGS=" -Donnxruntime_USE_CUDA=ON \ - -DCUDA_TOOLKIT_ROOT_DIR=$CUDA_ROOT \ - -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ - -Donnxruntime_CUDA_USE_TENSORRT=ON \ - " - else - echo "CUDA version is not 11.x or 12.x, installing ONNXRuntime basic CPU version" - ORT_BUILD_FLAGS="" + CUDA_VERSION=$(nvcc --version | grep "release" | awk '{print $NF}' | cut -dV -f2) + export ORT_CUDA_BUILD=1 + # if [[ "$CUDA_VERSION" == "V11" ]]; then + echo "Enabling ONNXRuntime build for CUDA (version ${CUDA_VERSION})" + ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} \ + -Donnxruntime_USE_CUDA=ON \ + -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ + " + if command -v 'find /usr -name "libnvinfer*"' >/dev/null 2>&1; then + ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} -Donnxruntime_CUDA_USE_TENSORRT=ON" fi else - echo "Installing ONNXRuntime basic CPU version" - ORT_BUILD_FLAGS="" + echo "Building ONNXRuntime basic CPU version" + export ORT_CPU_BUILD=1 fi ;; esac @@ -82,6 +79,7 @@ cmake "$SOURCEDIR/cmake" -Donnxruntime_PREFER_SYSTEM_LIB=ON \ -Donnxruntime_BUILD_SHARED_LIB=ON \ -DProtobuf_USE_STATIC_LIBS=ON \ + -Donnxruntime_ENABLE_TRAINING=OFF \ ${PROTOBUF_ROOT:+-DProtobuf_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf.a} \ ${PROTOBUF_ROOT:+-DProtobuf_LITE_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf-lite.a} \ ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_LIBRARY=$PROTOBUF_ROOT/lib/libprotoc.a} \ From e90a9e58ec8fecb1d79821ce1dea37f7b8dca25e Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Fri, 4 Oct 2024 09:27:30 +0200 Subject: [PATCH 06/19] This builds ORT with the GPU flags. Note: In the al9_gpu container the build with CUDA and ROCm fails due to a ROCm internal check for THRUST and CUB libraries, which are not in sync (file: /opt/rocm/include/thrust/system/cuda/config.h) --- onnxruntime.sh | 128 +++++++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 67 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 6d16dc4e5c..023983aac7 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -19,74 +19,68 @@ prepend_path: mkdir -p $INSTALLROOT -ORT_BUILD_FLAGS="" -case $ARCHITECTURE in - osx_*) - if [[ $ARCHITECTURE == *_x86-64 ]]; then - echo "Installing ONNXRuntime for MacOS (CPU version)" - else - echo "Installing ONNXRuntime for MacOS (Metal backend)" - fi - ;; - *) - if command -v rocminfo >/dev/null 2>&1; then - echo "Enabling ONNXRuntime build for ROCm" - export ORT_ROCM_BUILD=1 - if command -v find /opt/rocm* -name "libmigraphx*" >/dev/null 2>&1; then - echo " - ROCm build with MIGraphX" - export ORT_MIGRAPHX_BUILD=1 - ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} -Donnxruntime_USE_MIGRAPHX=ON" - fi - ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} \ - -Donnxruntime_USE_ROCM=ON \ - -Donnxruntime_ROCM_HOME=/opt/rocm \ - -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ - -D__HIP_PLATFORM_AMD__=1 \ - -DCMAKE_HIP_ARCHITECTURES=gfx906,gfx908 \ - -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ - -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ - -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ - -Donnxruntime_DISABLE_RTTI=OFF \ - -Donnxruntime_ENABLE_TRAINING=OFF \ - -DMSVC=OFF \ - " - elif command -v nvcc >/dev/null 2>&1; then - CUDA_VERSION=$(nvcc --version | grep "release" | awk '{print $NF}' | cut -dV -f2) - export ORT_CUDA_BUILD=1 - # if [[ "$CUDA_VERSION" == "V11" ]]; then - echo "Enabling ONNXRuntime build for CUDA (version ${CUDA_VERSION})" - ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} \ - -Donnxruntime_USE_CUDA=ON \ - -Donnxruntime_USE_CUDA_NHWC_OPS=ON \ - " - if command -v 'find /usr -name "libnvinfer*"' >/dev/null 2>&1; then - ORT_BUILD_FLAGS="${ORT_BUILD_FLAGS} -Donnxruntime_CUDA_USE_TENSORRT=ON" - fi - else - echo "Building ONNXRuntime basic CPU version" - export ORT_CPU_BUILD=1 - fi - ;; -esac +# Check ROCm build conditions +if { [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_HIP" -ne 0 ] || command -v rocminfo >/dev/null 2>&1; } && \ + { [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ]; }; then + export ORT_ROCM_BUILD=1 +else + export ORT_ROCM_BUILD=0 +fi +# Check CUDA build conditions +if { [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_CUDA" -ne 0 ] || command -v nvcc >/dev/null 2>&1; } && \ + { [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ]; }; then + export ORT_CUDA_BUILD=1 +else + export ORT_CUDA_BUILD=0 +fi -cmake "$SOURCEDIR/cmake" \ - $ORT_BUILD_FLAGS \ - -DCMAKE_INSTALL_PREFIX=$INSTALLROOT \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \ - -Donnxruntime_BUILD_UNIT_TESTS=OFF \ - -Donnxruntime_PREFER_SYSTEM_LIB=ON \ - -Donnxruntime_BUILD_SHARED_LIB=ON \ - -DProtobuf_USE_STATIC_LIBS=ON \ - -Donnxruntime_ENABLE_TRAINING=OFF \ - ${PROTOBUF_ROOT:+-DProtobuf_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf.a} \ - ${PROTOBUF_ROOT:+-DProtobuf_LITE_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf-lite.a} \ - ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_LIBRARY=$PROTOBUF_ROOT/lib/libprotoc.a} \ - ${PROTOBUF_ROOT:+-DProtobuf_INCLUDE_DIR=$PROTOBUF_ROOT/include} \ - ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_EXECUTABLE=$PROTOBUF_ROOT/bin/protoc} \ - ${RE2_ROOT:+-DRE2_INCLUDE_DIR=${RE2_ROOT}/include} \ - ${BOOST_ROOT:+-DBOOST_INCLUDE_DIR=${BOOST_ROOT}/include} \ +# Optional builds +### MIGraphX +if [ "$ORT_ROCM_BUILD" -eq 1 ] && [ $(find /opt/rocm* -name "libmigraphx*" -print -quit | wc -l 2>&1) -eq 1 ]; then + export ORT_MIGRAPHX_BUILD=1 +else + export ORT_MIGRAPHX_BUILD=0 +fi +### TensorRT +if [ "$ORT_CUDA_BUILD" -eq 1 ] && [ $(find /opt/rocm* -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ]; then + export ORT_TENSORRT_BUILD=1 +else + export ORT_TENSORRT_BUILD=0 +fi + +cmake "$SOURCEDIR/cmake" \ + -DCMAKE_INSTALL_PREFIX=$INSTALLROOT \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \ + -Donnxruntime_BUILD_UNIT_TESTS=OFF \ + -Donnxruntime_PREFER_SYSTEM_LIB=ON \ + -Donnxruntime_BUILD_SHARED_LIB=ON \ + -DProtobuf_USE_STATIC_LIBS=ON \ + -Donnxruntime_ENABLE_TRAINING=OFF \ + ${PROTOBUF_ROOT:+-DProtobuf_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf.a} \ + ${PROTOBUF_ROOT:+-DProtobuf_LITE_LIBRARY=$PROTOBUF_ROOT/lib/libprotobuf-lite.a} \ + ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_LIBRARY=$PROTOBUF_ROOT/lib/libprotoc.a} \ + ${PROTOBUF_ROOT:+-DProtobuf_INCLUDE_DIR=$PROTOBUF_ROOT/include} \ + ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_EXECUTABLE=$PROTOBUF_ROOT/bin/protoc} \ + ${RE2_ROOT:+-DRE2_INCLUDE_DIR=${RE2_ROOT}/include} \ + ${BOOST_ROOT:+-DBOOST_INCLUDE_DIR=${BOOST_ROOT}/include} \ + -Donnxruntime_USE_MIGRAPHX=${ORT_MIGRAPHX_BUILD} \ + -Donnxruntime_USE_ROCM=${ORT_ROCM_BUILD} \ + -Donnxruntime_ROCM_HOME=/opt/rocm \ + -Donnxruntime_CUDA_HOME=/usr/local/cuda \ + -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ + -D__HIP_PLATFORM_AMD__=1 \ + -DCMAKE_HIP_ARCHITECTURES=gfx906,gfx908 \ + ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:+-DCMAKE_HIP_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_HIP_ARCHS}} \ + -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ + -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ + -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ + -Donnxruntime_DISABLE_RTTI=OFF \ + -DMSVC=OFF \ + -Donnxruntime_USE_CUDA=${ORT_CUDA_BUILD} \ + -Donnxruntime_USE_CUDA_NHWC_OPS=${ORT_CUDA_BUILD} \ + -Donnxruntime_CUDA_USE_TENSORRT=${ORT_TENSORRT_BUILD} \ -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated" \ -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated" From d7b089dae1d03fd12a69c5b69f90f11f95cffb8c Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Fri, 4 Oct 2024 20:30:15 +0200 Subject: [PATCH 07/19] Adding comments and reshuffeling for better readibility --- onnxruntime.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 023983aac7..02b17cb0d5 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -20,9 +20,10 @@ prepend_path: mkdir -p $INSTALLROOT # Check ROCm build conditions -if { [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_HIP" -ne 0 ] || command -v rocminfo >/dev/null 2>&1; } && \ +if { [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_HIP" -ne 0 ] || command -v /opt/rocm/bin/rocminfo >/dev/null 2>&1; } && \ { [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ]; }; then export ORT_ROCM_BUILD=1 + : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} else export ORT_ROCM_BUILD=0 fi @@ -42,7 +43,7 @@ else export ORT_MIGRAPHX_BUILD=0 fi ### TensorRT -if [ "$ORT_CUDA_BUILD" -eq 1 ] && [ $(find /opt/rocm* -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ]; then +if [ "$ORT_CUDA_BUILD" -eq 1 ] && [ $(find /usr -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ]; then export ORT_TENSORRT_BUILD=1 else export ORT_TENSORRT_BUILD=0 @@ -65,22 +66,22 @@ cmake "$SOURCEDIR/cmake" ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_EXECUTABLE=$PROTOBUF_ROOT/bin/protoc} \ ${RE2_ROOT:+-DRE2_INCLUDE_DIR=${RE2_ROOT}/include} \ ${BOOST_ROOT:+-DBOOST_INCLUDE_DIR=${BOOST_ROOT}/include} \ - -Donnxruntime_USE_MIGRAPHX=${ORT_MIGRAPHX_BUILD} \ -Donnxruntime_USE_ROCM=${ORT_ROCM_BUILD} \ + ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:+-DCMAKE_HIP_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_HIP_ARCHS}} \ + -D__HIP_PLATFORM_AMD__=${ORT_ROCM_BUILD} \ + -Donnxruntime_USE_ROCBLAS_EXTENSION_API=${ORT_ROCM_BUILD} \ -Donnxruntime_ROCM_HOME=/opt/rocm \ - -Donnxruntime_CUDA_HOME=/usr/local/cuda \ -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ - -D__HIP_PLATFORM_AMD__=1 \ - -DCMAKE_HIP_ARCHITECTURES=gfx906,gfx908 \ - ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:+-DCMAKE_HIP_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_HIP_ARCHS}} \ + -Donnxruntime_USE_MIGRAPHX=${ORT_MIGRAPHX_BUILD} \ + -Donnxruntime_USE_CUDA=${ORT_CUDA_BUILD} \ + ${ALIBUILD_O2_OVERRIDE_CUDA_ARCH:+-CMAKE_CUDA_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_CUDA_ARCHS}} \ + -Donnxruntime_USE_CUDA_NHWC_OPS=${ORT_CUDA_BUILD} \ + -Donnxruntime_CUDA_HOME=/usr/local/cuda \ + -Donnxruntime_CUDA_USE_TENSORRT=${ORT_TENSORRT_BUILD} \ -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ - -Donnxruntime_USE_ROCBLAS_EXTENSION_API=ON \ -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ -Donnxruntime_DISABLE_RTTI=OFF \ -DMSVC=OFF \ - -Donnxruntime_USE_CUDA=${ORT_CUDA_BUILD} \ - -Donnxruntime_USE_CUDA_NHWC_OPS=${ORT_CUDA_BUILD} \ - -Donnxruntime_CUDA_USE_TENSORRT=${ORT_TENSORRT_BUILD} \ -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated" \ -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated" From d45d1944b67d3c08a9e7bff3620377c597cdfd6c Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Mon, 18 Nov 2024 11:25:46 +0100 Subject: [PATCH 08/19] Adding checks for Cuda and ROCm libraries --- onnxruntime.sh | 72 +++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 02b17cb0d5..fca4a5e2be 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -1,6 +1,6 @@ package: ONNXRuntime version: "%(tag_basename)s" -tag: v1.19.0 +tag: v1.15.0 source: https://github.com/microsoft/onnxruntime requires: - protobuf @@ -20,33 +20,51 @@ prepend_path: mkdir -p $INSTALLROOT # Check ROCm build conditions -if { [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_HIP" -ne 0 ] || command -v /opt/rocm/bin/rocminfo >/dev/null 2>&1; } && \ - { [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ]; }; then - export ORT_ROCM_BUILD=1 + +if [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_HIP" -ne 0 ] || \ + ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ + ( command -v /opt/rocm/bin/rocminfo >/dev/null 2>&1 ) && \ + [ -d /opt/rocm/include/hiprand ] && \ + [ -d /opt/rocm/include/hipblas ] && \ + [ -d /opt/rocm/include/hipsparse ] && \ + [ -d /opt/rocm/include/hipfft ] && \ + [ -d /opt/rocm/include/rocblas ] && \ + [ -d /opt/rocm/include/rocrand ] && \ + [ -d /opt/rocm/include/miopen ] && \ + [ -d /opt/rocm/include/rccl ] && \ + [ -z "$ORT_ROCM_BUILD" ] ); then + export ORT_ROCM_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} else - export ORT_ROCM_BUILD=0 + export ORT_ROCM_BUILD=0 fi + # Check CUDA build conditions -if { [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_CUDA" -ne 0 ] || command -v nvcc >/dev/null 2>&1; } && \ - { [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ]; }; then - export ORT_CUDA_BUILD=1 +if [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_CUDA" -ne 0 ] || \ + ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ + ( command -v nvcc >/dev/null 2>&1 ) && \ + [ -f /usr/include/cudnn.h ] && \ + [ -z "$ORT_CUDA_BUILD" ] ); then + export ORT_CUDA_BUILD=1 + : ${ALIBUILD_O2_OVERRIDE_CUDA_ARCHS:="sm_86"} else - export ORT_CUDA_BUILD=0 + export ORT_CUDA_BUILD=0 fi # Optional builds ### MIGraphX -if [ "$ORT_ROCM_BUILD" -eq 1 ] && [ $(find /opt/rocm* -name "libmigraphx*" -print -quit | wc -l 2>&1) -eq 1 ]; then - export ORT_MIGRAPHX_BUILD=1 -else - export ORT_MIGRAPHX_BUILD=0 +if ( [ "$ORT_ROCM_BUILD" -eq 1 ] && [ $(find /opt/rocm* -name "libmigraphx*" -print -quit | wc -l 2>&1) -eq 1 ] ) && \ + [ -z "$ORT_MIGRAPHX_BUILD" ]; then + export ORT_MIGRAPHX_BUILD=1 +elif [ -z "$ORT_MIGRAPHX_BUILD" ]; then + export ORT_MIGRAPHX_BUILD=0 fi ### TensorRT -if [ "$ORT_CUDA_BUILD" -eq 1 ] && [ $(find /usr -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ]; then - export ORT_TENSORRT_BUILD=1 -else - export ORT_TENSORRT_BUILD=0 +if ( [ "$ORT_CUDA_BUILD" -eq 1 ] && [ $(find /usr -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ] ) && \ + [ -z "$ORT_MIGRAPHX_BUILD" ]; then + export ORT_TENSORRT_BUILD=1 +elif [ -z "$ORT_TENSORRT_BUILD" ]; then + export ORT_TENSORRT_BUILD=0 fi cmake "$SOURCEDIR/cmake" \ @@ -66,24 +84,24 @@ cmake "$SOURCEDIR/cmake" ${PROTOBUF_ROOT:+-DProtobuf_PROTOC_EXECUTABLE=$PROTOBUF_ROOT/bin/protoc} \ ${RE2_ROOT:+-DRE2_INCLUDE_DIR=${RE2_ROOT}/include} \ ${BOOST_ROOT:+-DBOOST_INCLUDE_DIR=${BOOST_ROOT}/include} \ + -Donnxruntime_USE_MIGRAPHX=${ORT_MIGRAPHX_BUILD} \ -Donnxruntime_USE_ROCM=${ORT_ROCM_BUILD} \ - ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:+-DCMAKE_HIP_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_HIP_ARCHS}} \ - -D__HIP_PLATFORM_AMD__=${ORT_ROCM_BUILD} \ - -Donnxruntime_USE_ROCBLAS_EXTENSION_API=${ORT_ROCM_BUILD} \ -Donnxruntime_ROCM_HOME=/opt/rocm \ + -Donnxruntime_CUDA_HOME=/usr/local/cuda \ -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ \ - -Donnxruntime_USE_MIGRAPHX=${ORT_MIGRAPHX_BUILD} \ - -Donnxruntime_USE_CUDA=${ORT_CUDA_BUILD} \ + -D__HIP_PLATFORM_AMD__=${ORT_ROCM_BUILD} \ + ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:+-DCMAKE_HIP_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_HIP_ARCHS}} \ ${ALIBUILD_O2_OVERRIDE_CUDA_ARCH:+-CMAKE_CUDA_ARCHITECTURES=${ALIBUILD_O2_OVERRIDE_CUDA_ARCHS}} \ - -Donnxruntime_USE_CUDA_NHWC_OPS=${ORT_CUDA_BUILD} \ - -Donnxruntime_CUDA_HOME=/usr/local/cuda \ - -Donnxruntime_CUDA_USE_TENSORRT=${ORT_TENSORRT_BUILD} \ -Donnxruntime_USE_COMPOSABLE_KERNEL=OFF \ + -Donnxruntime_USE_ROCBLAS_EXTENSION_API=${ORT_ROCM_BUILD} \ -Donnxruntime_USE_COMPOSABLE_KERNEL_CK_TILE=ON \ -Donnxruntime_DISABLE_RTTI=OFF \ -DMSVC=OFF \ - -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated" \ - -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated" + -Donnxruntime_USE_CUDA=${ORT_CUDA_BUILD} \ + -Donnxruntime_USE_CUDA_NHWC_OPS=${ORT_CUDA_BUILD} \ + -Donnxruntime_CUDA_USE_TENSORRT=${ORT_TENSORRT_BUILD} \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated -Wno-error=maybe-uninitialized -Wno-error=template-id-cdtor" \ + -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated -Wno-error=maybe-uninitialized -Wno-error=template-id-cdtor" cmake --build . -- ${JOBS:+-j$JOBS} install From 000afbb579972c1420b64b8c9853acc80cc99ab9 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Tue, 19 Nov 2024 09:21:04 +0100 Subject: [PATCH 09/19] Updating to a recent version of ONNX --- onnxruntime.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index fca4a5e2be..6607e6a30c 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -1,6 +1,6 @@ package: ONNXRuntime version: "%(tag_basename)s" -tag: v1.15.0 +tag: v1.19.0 source: https://github.com/microsoft/onnxruntime requires: - protobuf From f28a341ef57f96bbae22826548e5dc0400d53442 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Fri, 22 Nov 2024 22:43:28 +0100 Subject: [PATCH 10/19] Changing to -eq 1 --- onnxruntime.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 6607e6a30c..d8e2ea7430 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -21,26 +21,26 @@ mkdir -p $INSTALLROOT # Check ROCm build conditions -if [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_HIP" -ne 0 ] || \ - ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ - ( command -v /opt/rocm/bin/rocminfo >/dev/null 2>&1 ) && \ - [ -d /opt/rocm/include/hiprand ] && \ - [ -d /opt/rocm/include/hipblas ] && \ - [ -d /opt/rocm/include/hipsparse ] && \ - [ -d /opt/rocm/include/hipfft ] && \ - [ -d /opt/rocm/include/rocblas ] && \ - [ -d /opt/rocm/include/rocrand ] && \ - [ -d /opt/rocm/include/miopen ] && \ - [ -d /opt/rocm/include/rccl ] && \ - [ -z "$ORT_ROCM_BUILD" ] ); then +if [ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ] || [ "$ALIBUILD_ENABLE_HIP" -eq 1 ] || \ + ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ + ( command -v /opt/rocm/bin/rocminfo >/dev/null 2>&1 ) && \ + [ -d /opt/rocm/include/hiprand ] && \ + [ -d /opt/rocm/include/hipblas ] && \ + [ -d /opt/rocm/include/hipsparse ] && \ + [ -d /opt/rocm/include/hipfft ] && \ + [ -d /opt/rocm/include/rocblas ] && \ + [ -d /opt/rocm/include/rocrand ] && \ + [ -d /opt/rocm/include/miopen ] && \ + [ -d /opt/rocm/include/rccl ] && \ + [ -z "$ORT_ROCM_BUILD" ] ); then export ORT_ROCM_BUILD=1 - : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} + : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} else export ORT_ROCM_BUILD=0 fi # Check CUDA build conditions -if [ "$ALIBUILD_O2_FORCE_GPU" -ne 0 ] || [ "$ALIBUILD_ENABLE_CUDA" -ne 0 ] || \ +if [ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ] || [ "$ALIBUILD_ENABLE_CUDA" -eq 1 ] || \ ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ ( command -v nvcc >/dev/null 2>&1 ) && \ [ -f /usr/include/cudnn.h ] && \ From 48132262fb23f7d1923bac72f5b9a63c7f21207f Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Tue, 26 Nov 2024 10:18:20 +0100 Subject: [PATCH 11/19] Changing to double-brace syntax --- onnxruntime.sh | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index d8e2ea7430..92ebba5710 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -21,18 +21,18 @@ mkdir -p $INSTALLROOT # Check ROCm build conditions -if [ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ] || [ "$ALIBUILD_ENABLE_HIP" -eq 1 ] || \ - ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ +if [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_HIP" -eq 1 ]] || \ + ( ( [[ -z "$DISABLE_GPU" ]] || [[ "$DISABLE_GPU" -eq 0 ]] ) && \ ( command -v /opt/rocm/bin/rocminfo >/dev/null 2>&1 ) && \ - [ -d /opt/rocm/include/hiprand ] && \ - [ -d /opt/rocm/include/hipblas ] && \ - [ -d /opt/rocm/include/hipsparse ] && \ - [ -d /opt/rocm/include/hipfft ] && \ - [ -d /opt/rocm/include/rocblas ] && \ - [ -d /opt/rocm/include/rocrand ] && \ - [ -d /opt/rocm/include/miopen ] && \ - [ -d /opt/rocm/include/rccl ] && \ - [ -z "$ORT_ROCM_BUILD" ] ); then + [[ -d /opt/rocm/include/hiprand ]] && \ + [[ -d /opt/rocm/include/hipblas ]] && \ + [[ -d /opt/rocm/include/hipsparse ]] && \ + [[ -d /opt/rocm/include/hipfft ]] && \ + [[ -d /opt/rocm/include/rocblas ]] && \ + [[ -d /opt/rocm/include/rocrand ]] && \ + [[ -d /opt/rocm/include/miopen ]] && \ + [[ -d /opt/rocm/include/rccl ]] && \ + [[ -z "$ORT_ROCM_BUILD" ]] ); then export ORT_ROCM_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} else @@ -40,11 +40,11 @@ else fi # Check CUDA build conditions -if [ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ] || [ "$ALIBUILD_ENABLE_CUDA" -eq 1 ] || \ - ( ( [ -z "$DISABLE_GPU" ] || [ "$DISABLE_GPU" -eq 0 ] ) && \ +if [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_CUDA" -eq 1 ]] || \ + ( ( [[ -z "$DISABLE_GPU" ]] || [[ "$DISABLE_GPU" -eq 0 ]] ) && \ ( command -v nvcc >/dev/null 2>&1 ) && \ - [ -f /usr/include/cudnn.h ] && \ - [ -z "$ORT_CUDA_BUILD" ] ); then + [[ -f /usr/include/cudnn.h ]] && \ + [[ -z "$ORT_CUDA_BUILD" ]] ); then export ORT_CUDA_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_CUDA_ARCHS:="sm_86"} else @@ -53,17 +53,17 @@ fi # Optional builds ### MIGraphX -if ( [ "$ORT_ROCM_BUILD" -eq 1 ] && [ $(find /opt/rocm* -name "libmigraphx*" -print -quit | wc -l 2>&1) -eq 1 ] ) && \ - [ -z "$ORT_MIGRAPHX_BUILD" ]; then +if ( [[ "$ORT_ROCM_BUILD" -eq 1 ]] && [[ $(find /opt/rocm* -name "libmigraphx*" -print -quit | wc -l 2>&1) -eq 1 ]] ) && \ + [[ -z "$ORT_MIGRAPHX_BUILD" ]]; then export ORT_MIGRAPHX_BUILD=1 -elif [ -z "$ORT_MIGRAPHX_BUILD" ]; then +elif [[ -z "$ORT_MIGRAPHX_BUILD" ]]; then export ORT_MIGRAPHX_BUILD=0 fi ### TensorRT -if ( [ "$ORT_CUDA_BUILD" -eq 1 ] && [ $(find /usr -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ] ) && \ - [ -z "$ORT_MIGRAPHX_BUILD" ]; then +if ( [[ "$ORT_CUDA_BUILD" -eq 1 ]] && [[ $(find /usr -name "libnvinfer*" -print -quit | wc -l 2>&1) -eq 1 ]] ) && \ + [[ -z "$ORT_MIGRAPHX_BUILD" ]]; then export ORT_TENSORRT_BUILD=1 -elif [ -z "$ORT_TENSORRT_BUILD" ]; then +elif [[ -z "$ORT_TENSORRT_BUILD" ]]; then export ORT_TENSORRT_BUILD=0 fi From 2713a612f0cc5baf0d98cb7b399e498775a46f90 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Tue, 26 Nov 2024 16:25:15 +0100 Subject: [PATCH 12/19] Changing to version 1.20 since 1.19 has issues for GPU execution --- onnxruntime.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 92ebba5710..5a4d5357bf 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -1,6 +1,6 @@ package: ONNXRuntime version: "%(tag_basename)s" -tag: v1.19.0 +tag: v1.20.0 source: https://github.com/microsoft/onnxruntime requires: - protobuf From 62ece4e12cdbd619b91cda7dd057a024152acea8 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Thu, 28 Nov 2024 14:28:29 +0100 Subject: [PATCH 13/19] Adding check for Alma9 (if system is AlmaLinux). exports's still need to passed to o2.sh --- onnxruntime.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 5a4d5357bf..24c089b307 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -20,6 +20,9 @@ prepend_path: mkdir -p $INSTALLROOT # Check ROCm build conditions +if [[ -f /etc/redhat-release ]]; then + export ALMA_LINUX_MAJOR_VERSION=$(awk '{print $3}' /etc/redhat-release | cut -d. -f1) +fi if [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_HIP" -eq 1 ]] || \ ( ( [[ -z "$DISABLE_GPU" ]] || [[ "$DISABLE_GPU" -eq 0 ]] ) && \ @@ -32,9 +35,11 @@ if [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_HIP" -eq 1 ]] || [[ -d /opt/rocm/include/rocrand ]] && \ [[ -d /opt/rocm/include/miopen ]] && \ [[ -d /opt/rocm/include/rccl ]] && \ - [[ -z "$ORT_ROCM_BUILD" ]] ); then + [[ -z "$ORT_ROCM_BUILD" ]] && \ + ([[ -z "$ALMA_LINUX_MAJOR_VERSION" ]] || [[ "$ALMA_LINUX_MAJOR_VERSION" -eq 9 ]]) ); then export ORT_ROCM_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib else export ORT_ROCM_BUILD=0 fi @@ -110,7 +115,6 @@ mkdir -p "$INSTALLROOT/etc/modulefiles" MODULEFILE="$INSTALLROOT/etc/modulefiles/$PKGNAME" alibuild-generate-module --lib > "$MODULEFILE" cat >> "$MODULEFILE" < Date: Thu, 28 Nov 2024 14:29:24 +0100 Subject: [PATCH 14/19] Adding compile flags for ONNXRuntime --- o2.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/o2.sh b/o2.sh index c069b1dd1b..73e26c706c 100644 --- a/o2.sh +++ b/o2.sh @@ -207,7 +207,11 @@ cmake $SOURCEDIR -DCMAKE_INSTALL_PREFIX=$INSTALLROOT ${ARROW_ROOT:+-DArrow_DIR=$ARROW_ROOT/lib/cmake/Arrow} \ ${CLANG_REVISION:+-DCLANG_EXECUTABLE="$CLANG_ROOT/bin-safe/clang"} \ ${CLANG_REVISION:+-DLLVM_LINK_EXECUTABLE="$CLANG_ROOT/bin/llvm-link"} \ - ${ITSRESPONSE_ROOT:+-DITSRESPONSE=${ITSRESPONSE_ROOT}} + ${ITSRESPONSE_ROOT:+-DITSRESPONSE=${ITSRESPONSE_ROOT}} \ + ${ORT_ROCM_BUILD:+-DORT_ROCM_BUILD=${ORT_ROCM_BUILD}} \ + ${ORT_CUDA_BUILD:+-DORT_CUDA_BUILD=${ORT_CUDA_BUILD}} \ + ${ORT_MIGRAPHX_BUILD:+-DORT_MIGRAPHX_BUILD=${ORT_MIGRAPHX_BUILD}} \ + ${ORT_TENSORRT_BUILD:+-DORT_TENSORRT_BUILD=${ORT_TENSORRT_BUILD}} # LLVM_ROOT is required for Gandiva cmake --build . -- ${JOBS+-j $JOBS} install From ae214b5f2062f4d461317dcd41c0d77bf801b71e Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Fri, 29 Nov 2024 13:58:53 +0100 Subject: [PATCH 15/19] Adding AlmaLinux 9 as general &&-check --- onnxruntime.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 24c089b307..68a89e50d9 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -35,8 +35,8 @@ if [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_HIP" -eq 1 ]] || [[ -d /opt/rocm/include/rocrand ]] && \ [[ -d /opt/rocm/include/miopen ]] && \ [[ -d /opt/rocm/include/rccl ]] && \ - [[ -z "$ORT_ROCM_BUILD" ]] && \ - ([[ -z "$ALMA_LINUX_MAJOR_VERSION" ]] || [[ "$ALMA_LINUX_MAJOR_VERSION" -eq 9 ]]) ); then + [[ -z "$ORT_ROCM_BUILD" ]] ) && \ + ([[ -z "$ALMA_LINUX_MAJOR_VERSION" ]] || [[ "$ALMA_LINUX_MAJOR_VERSION" -eq 9 ]]); then export ORT_ROCM_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_HIP_ARCHS:="gfx906,gfx908"} export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib From 6f3d636f07445b8c7d3600d30e23c41c0fb517a2 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Fri, 29 Nov 2024 14:16:36 +0100 Subject: [PATCH 16/19] Adding ORT_ROCM_BUILD check for CUDA build --- onnxruntime.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 68a89e50d9..8f933a4073 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -45,11 +45,12 @@ else fi # Check CUDA build conditions -if [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_CUDA" -eq 1 ]] || \ +if ( [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_CUDA" -eq 1 ]] || \ ( ( [[ -z "$DISABLE_GPU" ]] || [[ "$DISABLE_GPU" -eq 0 ]] ) && \ ( command -v nvcc >/dev/null 2>&1 ) && \ [[ -f /usr/include/cudnn.h ]] && \ - [[ -z "$ORT_CUDA_BUILD" ]] ); then + [[ -z "$ORT_CUDA_BUILD" ]] ) ) && \ + [[ "$ORT_ROCM_BUILD" -eq 0 ]]; then export ORT_CUDA_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_CUDA_ARCHS:="sm_86"} else From f5fd93bddf70bd0339851a92748a93efdb93c5b1 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Sat, 30 Nov 2024 10:20:36 +0100 Subject: [PATCH 17/19] Removing C/CXX flag for template-id-cdtor --- onnxruntime.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index 8f933a4073..fac5b5b74b 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -106,8 +106,8 @@ cmake "$SOURCEDIR/cmake" -Donnxruntime_USE_CUDA=${ORT_CUDA_BUILD} \ -Donnxruntime_USE_CUDA_NHWC_OPS=${ORT_CUDA_BUILD} \ -Donnxruntime_CUDA_USE_TENSORRT=${ORT_TENSORRT_BUILD} \ - -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated -Wno-error=maybe-uninitialized -Wno-error=template-id-cdtor" \ - -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated -Wno-error=maybe-uninitialized -Wno-error=template-id-cdtor" + -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated -Wno-error=maybe-uninitialized" \ + -DCMAKE_C_FLAGS="$CFLAGS -Wno-unknown-warning -Wno-unknown-warning-option -Wno-pass-failed -Wno-error=unused-but-set-variable -Wno-pass-failed=transform-warning -Wno-error=deprecated -Wno-error=maybe-uninitialized" cmake --build . -- ${JOBS:+-j$JOBS} install From 5e0f296d5bcf61db1beb03a87b65081e24109cb1 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Sun, 1 Dec 2024 19:07:08 +0100 Subject: [PATCH 18/19] Force disabling for alma linux distribution --- onnxruntime.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onnxruntime.sh b/onnxruntime.sh index fac5b5b74b..44ac09ebcd 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -50,7 +50,8 @@ if ( [[ "$ALIBUILD_O2_FORCE_GPU" -eq 1 ]] || [[ "$ALIBUILD_ENABLE_CUDA" -eq 1 ]] ( command -v nvcc >/dev/null 2>&1 ) && \ [[ -f /usr/include/cudnn.h ]] && \ [[ -z "$ORT_CUDA_BUILD" ]] ) ) && \ - [[ "$ORT_ROCM_BUILD" -eq 0 ]]; then + [[ "$ORT_ROCM_BUILD" -eq 0 ]] && \ + [[ -z "$ALMA_LINUX_MAJOR_VERSION" ]]; then export ORT_CUDA_BUILD=1 : ${ALIBUILD_O2_OVERRIDE_CUDA_ARCHS:="sm_86"} else From e01351a051ee105e33a63f7a91fe180a92a1cbb6 Mon Sep 17 00:00:00 2001 From: Christian Sonnabend Date: Thu, 19 Dec 2024 13:23:31 +0100 Subject: [PATCH 19/19] Adding ORT variables to be available at build time (and LD_LIBRARY_PATH at runtime) --- o2.sh | 6 ++++++ onnxruntime.sh | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/o2.sh b/o2.sh index 73e26c706c..1dea80dfde 100644 --- a/o2.sh +++ b/o2.sh @@ -139,6 +139,12 @@ valid_defaults: #!/bin/sh export ROOTSYS=$ROOT_ROOT +source $ONNXRUNTIME_ROOT/etc/ort-init.sh + +echo "ORT_ROCM_BUILD: $ORT_ROCM_BUILD" +echo "ORT_CUDA_BUILD: $ORT_CUDA_BUILD" +echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" + # Making sure people do not have SIMPATH set when they build fairroot. # Unfortunately SIMPATH seems to be hardcoded in a bunch of places in # fairroot, so this really should be cleaned up in FairRoot itself for diff --git a/onnxruntime.sh b/onnxruntime.sh index 44ac09ebcd..4f701817a9 100644 --- a/onnxruntime.sh +++ b/onnxruntime.sh @@ -74,6 +74,14 @@ elif [[ -z "$ORT_TENSORRT_BUILD" ]]; then export ORT_TENSORRT_BUILD=0 fi +mkdir -p $INSTALLROOT/etc +cat << EOF > $INSTALLROOT/etc/ort-init.sh +export ORT_ROCM_BUILD=$ORT_ROCM_BUILD +export ORT_CUDA_BUILD=$ORT_CUDA_BUILD +export ORT_MIGRAPHX_BUILD=$ORT_MIGRAPHX_BUILD +export ORT_TENSORRT_BUILD=$ORT_TENSORRT_BUILD +EOF + cmake "$SOURCEDIR/cmake" \ -DCMAKE_INSTALL_PREFIX=$INSTALLROOT \ -DCMAKE_BUILD_TYPE=Release \ @@ -120,4 +128,5 @@ cat >> "$MODULEFILE" <