-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
127 lines (115 loc) · 3.2 KB
/
Dockerfile
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
## Dockerfile to build opencv from sources with CUDA support
## Creator : Thomas Herbin
## Heavily based on Josip Janzic file
##
## 20 december 2017
FROM nvidia/cuda:8.0-devel
ARG https_proxy
ARG http_proxy
########################
### OPENCV INSTALL ###
########################
ARG OPENCV_VERSION=3.4.0
ARG OPENCV_INSTALL_PATH=/opencv/usr
RUN apt-get update && \
apt-get install -y \
python-pip \
build-essential \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libjasper-dev \
libavformat-dev \
libpq-dev \
libxine2-dev \
libglew-dev \
libtiff5-dev \
zlib1g-dev \
libjpeg-dev \
libpng12-dev \
libjasper-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libpostproc-dev \
libswscale-dev \
libeigen3-dev \
libtbb-dev \
libgtk2.0-dev \
pkg-config \
##
## Python
python-dev \
python-numpy \
python3-dev \
python3-numpy \
## VTK
#libvtk6-dev \
## Cleanup
&& rm -rf /var/lib/apt/lists/*
#RUN pip install numpy
## Create install directory
## Force success as the only reason for a fail is if it exist
RUN mkdir -p $OPENCV_INSTALL_PATH; exit 0
WORKDIR /
## Single command to reduce image size
## Build opencv
RUN wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip \
&& unzip $OPENCV_VERSION.zip \
&& mkdir /opencv-$OPENCV_VERSION/cmake_binary \
&& cd /opencv-$OPENCV_VERSION/cmake_binary \
&& cmake -DBUILD_TIFF=ON \
-DBUILD_opencv_java=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_CUDA=ON \
# -DENABLE_FAST_MATH=1 \
# -DCUDA_FAST_MATH=1 \
# -DWITH_CUBLAS=1 \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
##
## Should compile for most card
## 3.5 binary code for devices with compute capability 3.5 and 3.7,
## 5.0 binary code for devices with compute capability 5.0 and 5.2,
## 6.0 binary code for devices with compute capability 6.0 and 6.1,
-DCUDA_ARCH_BIN='3.0 3.5 5.0 6.0 6.2' \
-DCUDA_ARCH_PTX="" \
##
## AVX in dispatch because not all machines have it
-DCPU_DISPATCH=AVX,AVX2 \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-DWITH_OPENGL=OFF \
-DWITH_OPENCL=OFF \
-DWITH_QT=OFF \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DFORCE_VTK=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DWITH_XINE=ON \
-DWITH_GDAL=ON \
-DWITH_1394=OFF \
-DWITH_FFMPEG=OFF \
-DBUILD_PROTOBUF=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$OPENCV_INSTALL_PATH \
.. \
##
## Add variable to enable make to use all cores
&& export NUMPROC=$(nproc --all) \
&& make -j$NUMPROC install \
## Remove following lines if you need to move openCv
&& rm /$OPENCV_VERSION.zip \
&& rm -r /opencv-$OPENCV_VERSION
## Compress the openCV files so you can extract them from the docker easily
RUN tar cvzf opencv-$OPENCV_VERSION.tar.gz --directory=$OPENCV_INSTALL_PATH .