forked from kobewangSky/nano-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.opencv
80 lines (64 loc) · 3.21 KB
/
Dockerfile.opencv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM balenalib/jetson-nano-ubuntu:bionic as buildstep
WORKDIR /usr/src/app
COPY ./cuda-repo-l4t-10-0-local-10.0.166_1.0-1_arm64.deb .
ENV DEBIAN_FRONTEND noninteractive
## Install runtime & build libraries and build opencv
RUN \
dpkg -i cuda-repo-l4t-10-0-local-10.0.166_1.0-1_arm64.deb && \
apt-key add /var/cuda-repo-10-0-local-10.0.166/*.pub && \
apt-get update && \
apt-get install cuda-compiler-10-0 \
cuda-samples-10-0 \
lbzip2 xorg-dev \
cmake wget unzip \
libgtk2.0-dev pkg-config \
libavcodec-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libdc1394-22-dev -y --no-install-recommends && \
rm -rf ./*.deb && \
dpkg --remove cuda-repo-l4t-10-0-local-10.0.166 && \
dpkg -P cuda-repo-l4t-10-0-local-10.0.166 && \
echo "/usr/lib/aarch64-linux-gnu/tegra" > /etc/ld.so.conf.d/nvidia-tegra.conf \
&& ldconfig && \
wget https://github.com/opencv/opencv/archive/4.0.1.zip && \
unzip 4.0.1.zip && rm 4.0.1.zip
RUN \
wget https://github.com/opencv/opencv_contrib/archive/4.0.1.zip -O opencv_modules.4.0.1.zip && \
unzip opencv_modules.4.0.1.zip && rm opencv_modules.4.0.1.zip && \
export CUDA_HOME=/usr/local/cuda-10.0/ && \
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 && \
PATH=${CUDA_HOME}/bin:${PATH} && export PATH && \
mkdir -p opencv-4.0.1/build && cd opencv-4.0.1/build && \
cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D BUILD_LIST=cudev,highgui,videoio,cudaimgproc,ximgproc -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules -D CUDA_ARCH_PTX="" -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=ON -D BUILD_PERF_TESTS=ON -D BUILD_SAMPLES=ON -D BUILD_EXAMPLES=ON -D CMAKE_BUILD_TYPE=RELEASE -D WITH_GTK=on -D BUILD_DOCS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local .. && make -j32 && make install && \
cp /usr/src/app/opencv-4.0.1/build/bin/opencv_version /usr/src/app/ && \
cp /usr/src/app/opencv-4.0.1/build/bin/example_ximgproc_paillou_demo /usr/src/app/ && \
cp /usr/src/app/opencv-4.0.1/build/bin/example_ximgproc_fourier_descriptors_demo /usr/src/app/ && \
cd /usr/src/app/ && rm -rf /usr/src/app/opencv-4.0.1 && \
mv opencv_contrib-4.0.1/samples/data/corridor.jpg /usr/src/app/ && \
rm -rf /usr/src/app/opencv_contrib-4.0.1
FROM balenalib/jetson-nano-ubuntu:bionic as final
# Uncomment if planning to use libs from here
#COPY --from=buildstep /usr/local/cuda-10.0 /usr/local/cuda-10.0
# Minimum CUDA runtime libraries
COPY --from=buildstep /usr/lib/aarch64-linux-gnu /usr/lib/aarch64-linux-gnu
# OpenCV runtime libraries
COPY --from=buildstep /usr/local/lib /usr/local/lib
# Demo apps
COPY --from=buildstep /usr/src/app/ /usr/src/app/
COPY ./nvidia_drivers.tbz2 .
COPY ./config.tbz2 .
ENV DEBIAN_FRONTEND noninteractive
# Prepare minimum of runtime libraries and X
RUN apt-get update && apt-get install lbzip2 xorg -y && \
tar xjf nvidia_drivers.tbz2 -C / && \
tar xjf config.tbz2 -C / --exclude=etc/hosts --exclude=etc/hostname && \
echo "/usr/lib/aarch64-linux-gnu/tegra" > /etc/ld.so.conf.d/nvidia-tegra.conf && ldconfig && \
rm -rf *.tbz2
ENV UDEV=1
ENV LD_LIBRARY_PATH=/usr/local/lib
WORKDIR /usr/src/app/
CMD [ "sleep", "infinity" ]