Last active
November 22, 2023 07:52
-
-
Save fengyuentau/bf9e54f80dbec4cc0ea13b8f8a985f0b to your computer and use it in GitHub Desktop.
Dockerfiles for cross-compiling/native-compiling and testing TIM-VX backend on x86_64 Ubuntu 20.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM yuentau/ocv_ubuntu:20.04 | |
WORKDIR /opt | |
RUN git clone https://github.com/opencv/opencv | |
RUN cmake -B opencv-build -D WITH_TIMVX=ON opencv | |
RUN cmake --build opencv-build -j 8 | |
# unit tests | |
# 1. setup env var | |
# 2. run tests | |
WORKDIR /opt | |
# Setup opencv_extra | |
RUN git clone -b 4.x --single-branch https://github.com/opencv/opencv_extra | |
ENV OPENCV_TEST_DATA_PATH=/opt/opencv_extra/testdata | |
# Setup for TIM-VX | |
ENV VIVANTE_SDK_DIR=/opt/opencv-build/3rdparty/libtim-vx/TIM-VX-bb164d7d95610b0ab40f120fb248443ae60d5f87/prebuilt-sdk/x86_64_linux | |
ENV LD_LIBRARY_PATH=$VIVANTE_SDK_DIR/lib | |
# Unit tests run on NPU only | |
RUN ./opencv-build/bin/opencv_test_dnn --gtest_filter="Test_Int8_layers.*/1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM yuentau/ocv_ubuntu:20.04 | |
WORKDIR /opt | |
# Download toolchain | |
# alternative link: https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz | |
RUN wget https://cnbj1.fds.api.xiaomi.com/mace/third-party/gcc-linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz && \ | |
tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz | |
ENV AARCH64_TOOLCHAIN_ROOT=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu | |
# Download source code | |
RUN git clone https://github.com/opencv/opencv | |
# Download and extract VIVANTE SDK | |
RUN wget https://github.com/VeriSilicon/TIM-VX/releases/download/v1.1.34.fix/aarch64_A311D_6.4.8.tgz && \ | |
tar xvf aarch64_A311D_6.4.8.tgz | |
ENV VIVANTE_SDK_DIR=/opt/aarch64_A311D_6.4.8 | |
# Configure for cross compilation. | |
# NOTE: CMAKE_SKIP_RPATH is turned off to link executable binaries correctly. | |
#. You may need to append option `NO_CMAKE_FIND_ROOT_PATH` into find_library in line 9 at file `opencv/cmake/OpenCVFindTIMVX.cmake` to have libraries found correctly. | |
RUN cmake -B opencv-build \ | |
-D CMAKE_TOOLCHAIN_FILE=/opt/opencv/platforms/linux/aarch64-gnu.toolchain.cmake \ | |
-D CMAKE_C_COMPILER=${AARCH64_TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-gcc \ | |
-D CMAKE_CXX_COMPILER=${AARCH64_TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-g++ \ | |
-D CMAKE_LINKER=${AARCH64_TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-ld \ | |
-D CMAKE_AR=${AARCH64_TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-ar \ | |
-D CMAKE_SKIP_RPATH=OFF \ | |
-D WITH_OPENCL=OFF \ | |
-D WITH_TIMVX=ON opencv | |
# Compile | |
RUN cmake --build opencv-build -j 8 |
thanks, I will file an issue.
Yes it is indeed in the Docker.crossplatform case. So the question is, would it work natively, if the propopsed change is applied there as well (did not test).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @tglander , could you file an issue in the opencv repository so that I can take a look for you? BTW, I have no problems if compiling natively on the board. Looks like it is a cross compilation problem to me.