mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
Initiate the build scripts for ARM ACL (#2652)
1. Add scripts to build Yocto image & toolchain 2. Update docker build scripts to support Onnxruntime build with ARM ACL 19.02/19.05
This commit is contained in:
parent
f7412899a1
commit
47503ec7a6
7 changed files with 222 additions and 4 deletions
50
tools/ci_build/github/linux/build_yocto.sh
Normal file
50
tools/ci_build/github/linux/build_yocto.sh
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
set -e -o -x
|
||||
SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
|
||||
TARGET_FOLDER="/datadrive/ARM"
|
||||
SOURCE_ROOT=$(realpath $SCRIPT_DIR/../../../../)
|
||||
YOCTO_VERSION="4.19"
|
||||
|
||||
while getopts f:y: parameter_Option
|
||||
do case "${parameter_Option}"
|
||||
in
|
||||
f) TARGET_FOLDER=${OPTARG};;
|
||||
y) YOCTO_VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
YOCTO_IMAGE="arm-yocto"
|
||||
IMX_BRANCH="imx-linux-warrior"
|
||||
IMX_MANIFEST="imx-4.19.35-1.1.0.xml"
|
||||
|
||||
if [ $YOCTO_VERSION = "4.14" ]; then
|
||||
IMX_BRANCH="imx-linux-sumo"
|
||||
IMX_MANIFEST="imx-4.14.98-2.0.0_machinelearning.xml"
|
||||
fi
|
||||
|
||||
cd $SCRIPT_DIR/docker
|
||||
docker build -t $YOCTO_IMAGE -f Dockerfile.arm_yocto .
|
||||
|
||||
if [ ! -f $TARGET_FOLDER/bin/repo ]; then
|
||||
mkdir $TARGET_FOLDER/bin
|
||||
curl https://storage.googleapis.com/git-repo-downloads/repo > $TARGET_FOLDER/bin/repo
|
||||
chmod a+x $TARGET_FOLDER/bin/repo
|
||||
fi
|
||||
|
||||
if [ ! -d $TARGET_FOLDER/fsl-arm-yocto-bsp ]; then
|
||||
mkdir $TARGET_FOLDER/fsl-arm-yocto-bsp
|
||||
cd $TARGET_FOLDER/fsl-arm-yocto-bsp
|
||||
$TARGET_FOLDER/bin/repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b $IMX_BRANCH -m $IMX_MANIFEST
|
||||
$TARGET_FOLDER/bin/repo sync
|
||||
fi
|
||||
|
||||
YOCTO_CONTAINER="arm_yocto"
|
||||
docker rm -f $YOCTO_CONTAINER || true
|
||||
docker run --name $YOCTO_CONTAINER --volume $TARGET_FOLDER/fsl-arm-yocto-bsp:/fsl-arm-yocto-bsp --volume $SOURCE_ROOT:/onnxruntime_src $YOCTO_IMAGE /bin/bash /onnxruntime_src/tools/ci_build/github/linux/yocto_build_toolchain.sh -y $YOCTO_VERSION &
|
||||
|
||||
wait $!
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
set -e
|
||||
exit $EXIT_CODE
|
||||
21
tools/ci_build/github/linux/docker/Dockerfile.arm_yocto
Normal file
21
tools/ci_build/github/linux/docker/Dockerfile.arm_yocto
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
ARG OS_VERSION=16.04
|
||||
FROM ubuntu:${OS_VERSION}
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends gawk wget git-core diffstat unzip vim \
|
||||
texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev python3-dev sudo cpio file ca-certificates bc locales \
|
||||
libsdl1.2-dev xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 help2man gcc \
|
||||
g++ make desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \
|
||||
mercurial autoconf automake groff curl lzop asciidoc u-boot-tools
|
||||
|
||||
RUN locale-gen en_US.UTF-8
|
||||
|
||||
ENV LC_ALL=en_US.UTF-8
|
||||
ENV LANG=en_US.UTF-8
|
||||
|
||||
ARG BUILD_UID=1000
|
||||
ARG BUILD_USER=ubuntu
|
||||
RUN adduser --gecos 'yocto build user' --disabled-password $BUILD_USER --uid $BUILD_UID && \
|
||||
usermod -aG sudo ubuntu
|
||||
|
||||
USER $BUILD_USER
|
||||
|
||||
18
tools/ci_build/github/linux/docker/Dockerfile.ubuntu_for_arm
Normal file
18
tools/ci_build/github/linux/docker/Dockerfile.ubuntu_for_arm
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
ARG OS_VERSION=16.04
|
||||
FROM ubuntu:${OS_VERSION}
|
||||
|
||||
ARG PYTHON_VERSION=3.5
|
||||
ADD scripts /tmp/scripts
|
||||
RUN /tmp/scripts/install_ubuntu.sh -p $PYTHON_VERSION -d EdgeDevice && \
|
||||
/tmp/scripts/install_deps.sh -p $PYTHON_VERSION -d EdgeDevice && \
|
||||
/tmp/scripts/install_protobuf.sh
|
||||
|
||||
ARG TOOL_CHAIN="fsl-imx-xwayland-glibc-x86_64-fsl-image-qt5-aarch64-toolchain-4.19-warrior.sh"
|
||||
RUN /tmp/scripts/$TOOL_CHAIN -y && rm -rf /tmp/scripts
|
||||
|
||||
ARG BUILD_UID=1000
|
||||
ARG BUILD_USER=onnxruntimedev
|
||||
RUN adduser --gecos 'onnxruntime Build User' --disabled-password $BUILD_USER --uid $BUILD_UID
|
||||
WORKDIR /home/$BUILD_USER
|
||||
USER $BUILD_USER
|
||||
|
||||
|
|
@ -1,5 +1,39 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
#Download a file from internet
|
||||
function GetFile {
|
||||
local uri=$1
|
||||
local path=$2
|
||||
local force=${3:-false}
|
||||
local download_retries=${4:-5}
|
||||
local retry_wait_time_seconds=${5:-30}
|
||||
|
||||
if [[ -f $path ]]; then
|
||||
if [[ $force = false ]]; then
|
||||
echo "File '$path' already exists. Skipping download"
|
||||
return 0
|
||||
else
|
||||
rm -rf $path
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f $uri ]]; then
|
||||
echo "'$uri' is a file path, copying file to '$path'"
|
||||
cp $uri $path
|
||||
return $?
|
||||
fi
|
||||
|
||||
echo "Downloading $uri"
|
||||
# Use aria2c if available, otherwise use curl
|
||||
if command -v aria2c > /dev/null; then
|
||||
aria2c -q -d $(dirname $path) -o $(basename $path) "$uri"
|
||||
else
|
||||
curl "$uri" -sSL --retry $download_retries --retry-delay $retry_wait_time_seconds --create-dirs -o "$path" --fail
|
||||
fi
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
GetFile https://github.com/protocolbuffers/protobuf/archive/v3.6.1.tar.gz /tmp/src/v3.6.1.tar.gz
|
||||
tar -xf /tmp/src/v3.6.1.tar.gz -C /tmp/src
|
||||
cd /tmp/src/protobuf-3.6.1
|
||||
|
|
|
|||
|
|
@ -4,13 +4,16 @@ set -e -o -x
|
|||
id
|
||||
|
||||
SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
|
||||
YOCTO_VERSION="4.19"
|
||||
|
||||
while getopts d:x:o: parameter_Option
|
||||
while getopts d:x:o:y: parameter_Option
|
||||
do case "${parameter_Option}"
|
||||
in
|
||||
d) BUILD_DEVICE=${OPTARG};;
|
||||
x) BUILD_EXTR_PAR=${OPTARG};;
|
||||
o) BUILD_OS=${OPTARG};;
|
||||
# YOCTO 4.19 + ACL 19.05, YOCTO 4.14 + ACL 19.02
|
||||
y) YOCTO_VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
@ -22,6 +25,21 @@ if [ $BUILD_OS = "android" ]; then
|
|||
else
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=/android-ndk/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc ../cmake
|
||||
fi
|
||||
make -j$(nproc)
|
||||
elif [ $BUILD_OS = "yocto" ]; then
|
||||
YOCTO_FOLDER="4.19-warrior"
|
||||
if [ $YOCTO_VERSION = "4.14" ]; then
|
||||
YOCTO_FOLDER="4.14-sumo"
|
||||
fi
|
||||
pushd /onnxruntime_src
|
||||
if [ ! -d build ]; then
|
||||
mkdir build
|
||||
fi
|
||||
cd build
|
||||
. /opt/fsl-imx-xwayland/$YOCTO_FOLDER/environment-setup-aarch64-poky-linux
|
||||
alias cmake="/usr/bin/cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake"
|
||||
cmake ../cmake -Donnxruntime_RUN_ONNX_TESTS=OFF -Donnxruntime_GENERATE_TEST_REPORTS=ON -Donnxruntime_DEV_MODE=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -Donnxruntime_USE_CUDA=OFF -Donnxruntime_USE_NSYNC=OFF -Donnxruntime_CUDNN_HOME= -Donnxruntime_USE_JEMALLOC=OFF -Donnxruntime_ENABLE_PYTHON=OFF -Donnxruntime_BUILD_CSHARP=OFF -Donnxruntime_USE_EIGEN_FOR_BLAS=ON -Donnxruntime_USE_OPENBLAS=OFF -Donnxruntime_USE_ACL=ON -Donnxruntime_USE_MKLDNN=OFF -Donnxruntime_USE_MKLML=OFF -Donnxruntime_USE_OPENMP=ON -Donnxruntime_USE_TVM=OFF -Donnxruntime_USE_LLVM=OFF -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF -Donnxruntime_USE_BRAINSLICE=OFF -Donnxruntime_USE_NUPHAR=OFF -Donnxruntime_USE_EIGEN_THREADPOOL=OFF -Donnxruntime_BUILD_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES:PATH=/opt/fsl-imx-xwayland/$YOCTO_FOLDER/sysroots/aarch64-poky-linux/usr/include -DCMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES:PATH=/opt/fsl-imx-xwayland/$YOCTO_FOLDER/sysroots/aarch64-poky-linux/usr/include -DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc
|
||||
|
||||
make -j$(nproc)
|
||||
else
|
||||
COMMON_BUILD_ARGS="--skip_submodule_sync --enable_onnx_tests --parallel --build_shared_lib --use_openmp --cmake_path /usr/bin/cmake --ctest_path /usr/bin/ctest"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ set -e -o -x
|
|||
SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
|
||||
SOURCE_ROOT=$(realpath $SCRIPT_DIR/../../../../)
|
||||
CUDA_VER=cuda10.0-cudnn7.3
|
||||
YOCTO_VERSION="4.19"
|
||||
|
||||
while getopts c:o:d:r:p:x:a:v: parameter_Option
|
||||
while getopts c:o:d:r:p:x:a:v:y: parameter_Option
|
||||
do case "${parameter_Option}"
|
||||
in
|
||||
#android, ubuntu16.04, manylinux2010, ubuntu18.04, CentOS7
|
||||
|
|
@ -23,6 +24,8 @@ c) CUDA_VER=${OPTARG};;
|
|||
a) BUILD_ARCH=${OPTARG};;
|
||||
# openvino version tag: 2018_R5, 2019_R1.1 (Default is 2019_R1.1)
|
||||
v) OPENVINO_VERSION=${OPTARG};;
|
||||
# YOCTO 4.19 + ACL 19.05, YOCTO 4.14 + ACL 19.02
|
||||
y) YOCTO_VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
@ -48,6 +51,15 @@ elif [ $BUILD_OS = "centos7" ]; then
|
|||
IMAGE="centos7"
|
||||
DOCKER_FILE=Dockerfile.centos
|
||||
docker build --pull -t "onnxruntime-$IMAGE" --build-arg BUILD_USER=onnxruntimedev --build-arg BUILD_UID=$(id -u) --build-arg PYTHON_VERSION=${PYTHON_VER} -f $DOCKER_FILE .
|
||||
elif [ $BUILD_OS = "yocto" ]; then
|
||||
IMAGE="arm-yocto-$YOCTO_VERSION"
|
||||
DOCKER_FILE=Dockerfile.ubuntu_for_arm
|
||||
# ACL 19.05 need yocto 4.19
|
||||
TOOL_CHAIN_SCRIPT=fsl-imx-xwayland-glibc-x86_64-fsl-image-qt5-aarch64-toolchain-4.19-warrior.sh
|
||||
if [ $YOCTO_VERSION = "4.14" ]; then
|
||||
TOOL_CHAIN_SCRIPT=fsl-imx-xwayland-glibc-x86_64-fsl-image-qt5-aarch64-toolchain-4.14-sumo.sh
|
||||
fi
|
||||
docker build -t "onnxruntime-$IMAGE" --build-arg TOOL_CHAIN=$TOOL_CHAIN_SCRIPT --build-arg BUILD_USER=onnxruntimedev --build-arg BUILD_UID=$(id -u) --build-arg PYTHON_VERSION=${PYTHON_VER} -f $DOCKER_FILE .
|
||||
else
|
||||
if [ $BUILD_DEVICE = "gpu" ]; then
|
||||
IMAGE="$BUILD_OS-$CUDA_VER"
|
||||
|
|
@ -84,7 +96,7 @@ if [ -z "$NIGHTLY_BUILD" ]; then
|
|||
set NIGHTLY_BUILD=0
|
||||
fi
|
||||
|
||||
if [ $BUILD_DEVICE = "cpu" ] || [ $BUILD_DEVICE = "ngraph" ] || [ $BUILD_DEVICE = "openvino" ] || [ $BUILD_DEVICE = "nnapi" ]; then
|
||||
if [ $BUILD_DEVICE = "cpu" ] || [ $BUILD_DEVICE = "ngraph" ] || [ $BUILD_DEVICE = "openvino" ] || [ $BUILD_DEVICE = "nnapi" ] || [ $BUILD_DEVICE = "arm" ]; then
|
||||
RUNTIME=
|
||||
else
|
||||
RUNTIME="--gpus all"
|
||||
|
|
@ -104,7 +116,7 @@ docker run $RUNTIME -h $HOSTNAME $DOCKER_RUN_PARAMETER \
|
|||
-e NIGHTLY_BUILD \
|
||||
"onnxruntime-$IMAGE" \
|
||||
/bin/bash /onnxruntime_src/tools/ci_build/github/linux/run_build.sh \
|
||||
-d $BUILD_DEVICE -x "$BUILD_EXTR_PAR" -o $BUILD_OS &
|
||||
-d $BUILD_DEVICE -x "$BUILD_EXTR_PAR" -o $BUILD_OS -y $YOCTO_VERSION &
|
||||
wait $!
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
|
|
|||
65
tools/ci_build/github/linux/yocto_build_toolchain.sh
Normal file
65
tools/ci_build/github/linux/yocto_build_toolchain.sh
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
YOCTO_VERSION="4.19"
|
||||
|
||||
while getopts y: parameter_Option
|
||||
do case "${parameter_Option}"
|
||||
in
|
||||
y) YOCTO_VERSION=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
LOCAL_CFG="/fsl-arm-yocto-bsp/buildxwayland/conf/local.conf"
|
||||
if [ -f $LOCAL_CFG ]; then
|
||||
rm -rf $LOCAL_CFG
|
||||
fi
|
||||
|
||||
cd /fsl-arm-yocto-bsp
|
||||
EULA=1 MACHINE=imx8qmmek DISTRO=fsl-imx-xwayland BUILD_DIR=buildxwayland source ./fsl-setup-release.sh
|
||||
if [ $YOCTO_VERSION = "4.14" ]; then
|
||||
echo "BBLAYERS += \" \${BSPDIR}/sources/meta-freescale-3rdparty \"" >> conf/bblayers.conf
|
||||
fi
|
||||
|
||||
if [ $YOCTO_VERSION = "4.14" ]; then
|
||||
cat >> $LOCAL_CFG <<EOT414
|
||||
EXTRA_IMAGE_FEATURES = " dev-pkgs debug-tweaks tools-debug tools-sdk ssh-server-openssh"
|
||||
|
||||
IMAGE_INSTALL_append = " net-tools iputils dhcpcd"
|
||||
|
||||
IMAGE_INSTALL_append = " which gzip python python-pip"
|
||||
IMAGE_INSTALL_append = " wget cmake gtest git zlib patchelf"
|
||||
IMAGE_INSTALL_append = " nano grep vim tmux swig tar unzip"
|
||||
IMAGE_INSTALL_append = " parted e2fsprogs e2fsprogs-resize2fs"
|
||||
|
||||
IMAGE_INSTALL_append = " opencv python-opencv"
|
||||
PACKAGECONFIG_remove_pn-opencv_mx8 = "python3"
|
||||
PACKAGECONFIG_append_pn-opencv_mx8 = " dnn python2 qt5 jasper openmp test neon"
|
||||
|
||||
PACKAGECONFIG_remove_pn-opencv_mx8 = "opencl"
|
||||
PACKAGECONFIG_remove_pn-arm-compute-library = "opencl"
|
||||
|
||||
TOOLCHAIN_HOST_TASK_append = " nativesdk-cmake nativesdk-make"
|
||||
|
||||
IMAGE_INSTALL_append = " arm-compute-library"
|
||||
PREFERRED_VERSION_opencv = "4.0.1%"
|
||||
|
||||
EOT414
|
||||
elif [ $YOCTO_VERSION = "4.19" ]; then
|
||||
cat >> $LOCAL_CFG <<EOT419
|
||||
EXTRA_IMAGE_FEATURES = " dev-pkgs debug-tweaks tools-debug tools-sdk ssh-server-openssh"
|
||||
|
||||
IMAGE_INSTALL_append = " net-tools iputils dhcpcd"
|
||||
IMAGE_INSTALL_append = " which gzip python python-pip"
|
||||
IMAGE_INSTALL_append = " wget cmake gtest git zlib patchelf"
|
||||
IMAGE_INSTALL_append = " nano grep vim tmux swig tar unzip"
|
||||
IMAGE_INSTALL_append = " parted e2fsprogs e2fsprogs-resize2fs"
|
||||
|
||||
TOOLCHAIN_HOST_TASK_append = " nativesdk-cmake nativesdk-make"
|
||||
|
||||
IMAGE_INSTALL_append = " arm-compute-library armnn"
|
||||
EOT419
|
||||
fi
|
||||
|
||||
bitbake fsl-image-qt5
|
||||
bitbake fsl-image-qt5 -c populate_sdk
|
||||
Loading…
Reference in a new issue