The following steps shows how to cross compiling ONNX Runtime on Ubuntu for Raspberry Pi with docker.
$ sudo apt install qemu qemu-user-static binfmt-support
$ git clone --recursive https://github.com/Microsoft/onnxruntime
$ cd onnxruntime
$ git checkout v1.10.0
$ git submodule update --init --recursive
Note: You can checkout another version of ONNX Runtime. For list of all tags, run git tag
command on terminal.
If your build failed, you should patch the following lines in the source code.
File onnxruntime/cmake/external/eigen/Eigen/src/Core/arch/NEON/PacketMath.h
:
- Line 1633: Change
memcpy(res, from, sizeof(Packet4c));
tomemcpy((void*)(&res), (const void*)from, sizeof(Packet4c));
. - Line 1678: Change
memcpy(res, from, sizeof(Packet4c));
tomemcpy((void*)(&res), (const void*)from, sizeof(Packet4c));
.
Note: Make sure your current working directory ponits to the root directory of onnxruntime source code.
$ pwd
$ docker container run \
--name onnxruntime \
--tty \
--interactive \
--volume $(pwd):/src \
arm32v7/fedora:34
Run the following commands in docker container terminal:
$ dnf install -y binutils
$ dnf install -y gcc
$ dnf install -y gcc-c++
$ dnf install -y git
$ dnf install -y cmake
$ dnf install -y aria2
$ cd /src
$ ./build.sh --help
$ ./build.sh \
--config Release \
--update \
--build \
--parallel \
--skip_tests \
--build_shared_lib \
--cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER)
$ exit
After successful build, build/Linux/Release
directory contains onnxruntime shared libraries.
- https://www.onnxruntime.ai
- https://github.com/microsoft/onnxruntime
- https://onnxruntime.ai/docs/build/inferencing.html#arm
- https://onnxruntime.ai/docs/build/inferencing.html#cross-compiling-for-arm-with-simulation-linuxwindows
- https://github.com/microsoft/onnxruntime/blob/master/dockerfiles/README.md#arm-3264