1
用 Docker 的方式编译 OpenVINO
发布于: 2021 年 06 月 06 日
本地编译始终过不去 ARM 插件的编译,于是打算用 Docker 的方式试一下。
先创建 Dockerfile
FROM debian:buster
USER root
RUN echo 'deb http://deb.debian.org/debian unstable main' > /etc/apt/sources.list.d/unstable.list
RUN dpkg --add-architecture armhf && \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
crossbuild-essential-armhf \
python3-dev \
python3-pip \
python3-numpy/unstable \
git-lfs \
scons \
wget \
xz-utils \
cmake \
libusb-1.0-0-dev:armhf \
libgtk-3-dev:armhf \
libavcodec-dev:armhf \
libavformat-dev:armhf \
libswscale-dev:armhf \
libgstreamer1.0-dev:armhf \
libgstreamer-plugins-base1.0-dev:armhf \
libpython3-dev:armhf && \
rm -rf /var/lib/apt/lists/*
COPY arm_build.sh /arm_build.sh
RUN mkdir /arm
WORKDIR /arm/
CMD ["sh", "/arm_build.sh"]
复制代码
在同级目录下面创建一个 sh 文件
#!/bin/sh
set -x
fail()
{
echo $1
exit 1
}
git clone --recurse-submodules --shallow-submodules --depth 1 https://github.com/opencv/opencv.git && \
git clone --recurse-submodules --shallow-submodules --depth 1 https://github.com/openvinotoolkit/openvino.git && \
git clone --recurse-submodules --shallow-submodules --depth 1 https://github.com/openvinotoolkit/openvino_contrib.git || \
fail "Failed to clone source repositories"
cd /arm/openvino && \
mkdir openvino_install && mkdir openvino_build && cd openvino_build && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="../openvino_install" \
-DCMAKE_TOOLCHAIN_FILE="../cmake/arm.toolchain.cmake" \
-DTHREADING=SEQ \
-DIE_EXTRA_MODULES=/arm/openvino_contrib/modules/arm_plugin \
-DTHREADS_PTHREAD_ARG="-pthread" .. \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_CXX_FLAGS=-latomic \
-DENABLE_TESTS=OFF -DENABLE_BEH_TESTS=OFF -DENABLE_FUNCTIONAL_TESTS=OFF && \
make --jobs=$(nproc --all) && make install && \
cp /arm/openvino/bin/armv7l/Release/lib/libarmPlugin.so \
/arm/openvino/openvino_install/deployment_tools/inference_engine/lib/armv7l/ || \
fail "OpenVINO build failed"
cd /arm/opencv && mkdir opencv_install && mkdir opencv_build && cd opencv_build && \
PYTHONVER=`ls /usr/include | grep "python3.*"` && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_LIST=imgcodecs,videoio,highgui,dnn,python3 \
-DCMAKE_INSTALL_PREFIX="../opencv_install" \
-DOPENCV_CONFIG_INSTALL_PATH="cmake" \
-DCMAKE_TOOLCHAIN_FILE="../platforms/linux/arm-gnueabi.toolchain.cmake" \
-DWITH_IPP=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DOPENCV_ENABLE_PKG_CONFIG=ON \
-DPYTHON3_PACKAGES_PATH="../opencv_install/python" \
-DPKG_CONFIG_EXECUTABLE="/usr/bin/arm-linux-gnueabihf-pkg-config" \
-DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=ON \
-DPYTHON3_INCLUDE_PATH="/usr/include/${PYTHONVER}" \
-DPYTHON3_NUMPY_INCLUDE_DIRS="/usr/lib/python3/dist-packages/numpy/core/include" \
-DPYTHON3_LIMITED_API=ON \
-DOPENCV_SKIP_PYTHON_LOADER=ON \
-DENABLE_NEON=ON \
-DCPU_BASELINE="NEON" \
-DWITH_INF_ENGINE=ON \
-DWITH_NGRAPH=ON \
-Dngraph_DIR="/arm/openvino/openvino_build/ngraph" \
-DINF_ENGINE_RELEASE=2021030000 \
-DInferenceEngine_DIR="/arm/openvino/openvino_build" \
-DINF_ENGINE_LIB_DIRS="/arm/openvino/bin/armv7l/Release/lib" \
-DINF_ENGINE_INCLUDE_DIRS="/arm/openvino/inference-engine/include" \
-DCMAKE_FIND_ROOT_PATH="/arm/openvino" \
-DENABLE_CXX11=ON .. && \
make --jobs=$(nproc --all) && make install || \
fail "OpenCV build failed"
复制代码
这里要经常访问因此在创建时需要挂在梯子,而且梯子质量最好好一些。
划线
评论
复制
发布于: 2021 年 06 月 06 日阅读数: 10
IT蜗壳-Tango
关注
一个日语专业的程序猿。 2017.09.10 加入
【坐标】无锡 【软件技能】Java,C#,Python 【爱好】炉石传说 【称号】InfoQ年度人气作者,Intel OpenVINO领航者联盟成员 【B站】https://space.bilibili.com/397260706/ 【个人站】www.it-worker.club
评论