Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewssobral/39c40695df7e414c72309f6e79d14c0a to your computer and use it in GitHub Desktop.
Save andrewssobral/39c40695df7e414c72309f6e79d14c0a to your computer and use it in GitHub Desktop.
How to build onnxruntime on an aarch64 NVIDIA device (like Jetson Orin AGX)
docker run \
--rm \
-it \
-e ONNXRUNTIME_REPO=https://github.com/microsoft/onnxruntime \
-e ONNXRUNTIME_COMMIT=v1.15.1 \
-e BUILD_CONFIG=Release \
-e CMAKE_VERSION=3.26.4 \
-e CPU_ARCHITECTURE=$(uname -m) \
-e CUDA_ARCHITECTURES="70;75;80;86" \
-v /usr/lib/aarch64-linux-gnu/tegra:/usr/lib/aarch64-linux-gnu/tegra:ro \
-v $(pwd):/output \
-w /tmp \
nvcr.io/nvidia/l4t-tensorrt:r8.5.2.2-devel \
/bin/bash -c "
# set up cmake
apt remove -y cmake &&\
rm -rf /usr/local/bin/cmake &&\
apt update &&\
apt install -y wget &&\
rm -rf /tmp/cmake &&\
mkdir /tmp/cmake &&\
wget https://github.com/Kitware/CMake/releases/download/v\${CMAKE_VERSION}/cmake-\${CMAKE_VERSION}-linux-\${CPU_ARCHITECTURE}.tar.gz &&\
tar zxf cmake-\${CMAKE_VERSION}-linux-\${CPU_ARCHITECTURE}.tar.gz --strip-components=1 -C /tmp/cmake &&\
export PATH=\$PATH:/tmp/cmake/bin &&\
# clone onnxruntime repository and build
apt-get install -y patch &&\
git clone \${ONNXRUNTIME_REPO} onnxruntime &&\
cd onnxruntime &&\
git checkout \${ONNXRUNTIME_COMMIT} &&\
grep -rl ORT_UNUSED_VARIABLE . | xargs sed -i 's/ORT_UNUSED_VARIABLE/ORT_UNUSED_PARAMETER/g' &&\
/bin/sh build.sh \
--parallel \
--build_shared_lib \
--allow_running_as_root \
--compile_no_warning_as_error \
--cuda_home /usr/local/cuda \
--cudnn_home /usr/lib/\${CPU_ARCHITECTURE}-linux-gnu/ \
--use_tensorrt \
--tensorrt_home /usr/lib/\${CPU_ARCHITECTURE}-linux-gnu/ \
--config \${BUILD_CONFIG} \
--skip_tests \
--cmake_extra_defines CMAKE_CUDA_ARCHITECTURES=\${CUDA_ARCHITECTURES} &&\
# package and copy to output
export ONNXRUNTIME_VERSION=\$(cat /tmp/onnxruntime/VERSION_NUMBER) &&\
rm -rf /tmp/onnxruntime/build/onnxruntime-linux-\${CPU_ARCHITECTURE}-gpu-\${ONNXRUNTIME_VERSION} &&\
BINARY_DIR=build \
ARTIFACT_NAME=onnxruntime-linux-\${CPU_ARCHITECTURE}-gpu-\${ONNXRUNTIME_VERSION} \
LIB_NAME=libonnxruntime.so \
BUILD_CONFIG=Linux/\${BUILD_CONFIG} \
SOURCE_DIR=/tmp/onnxruntime \
COMMIT_ID=\$(git rev-parse HEAD) \
tools/ci_build/github/linux/copy_strip_binary.sh &&\
cd /tmp/onnxruntime/build/onnxruntime-linux-\${CPU_ARCHITECTURE}-gpu-\${ONNXRUNTIME_VERSION}/lib/ &&\
ln -s libonnxruntime.so libonnxruntime.so.\${ONNXRUNTIME_VERSION} &&\
cp -r /tmp/onnxruntime/build/onnxruntime-linux-\${CPU_ARCHITECTURE}-gpu-\${ONNXRUNTIME_VERSION} /output
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment