-
Notifications
You must be signed in to change notification settings - Fork 57
/
Dockerfile-py2-cuda
92 lines (84 loc) · 2.31 KB
/
Dockerfile-py2-cuda
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
# https://www.learnopencv.com/install-opencv3-on-ubuntu/
FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04
LABEL maintainer "[email protected]"
ENV OPENCV_VERSION 3.4.2
# Install all dependencies for OpenCV
RUN apt-get -y update && \
apt-get -y install \
python2.7 \
python2.7-dev \
git \
wget \
unzip \
build-essential \
cmake \
pkg-config \
libatlas-base-dev \
gfortran \
libjasper-dev \
libgtk2.0-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libjasper-dev \
libv4l-dev \
&& \
# install python dependencies
wget https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py && \
pip install numpy \
&& \
# Install OpenCV
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -O opencv3.zip && \
unzip -q opencv3.zip && \
mv /opencv-$OPENCV_VERSION /opencv && \
rm opencv3.zip && \
wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip -O opencv_contrib3.zip && \
unzip -q opencv_contrib3.zip && \
mv /opencv_contrib-$OPENCV_VERSION /opencv_contrib && \
rm opencv_contrib3.zip \
&& \
# Prepare build
mkdir /opencv/build && cd /opencv/build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_PYTHON_SUPPORT=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
-D BUILD_EXAMPLES=OFF \
-D WITH_IPP=OFF \
-D WITH_FFMPEG=ON \
-D WITH_CUDA=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
-D WITH_CUBLAS=ON \
-D WITH_V4L=ON .. \
&& \
# Install
cd /opencv/build && \
make -j$(nproc) && \
make install && \
ldconfig \
&& \
# Clean
apt-get -y remove \
python2.7-dev \
libatlas-base-dev \
gfortran \
libjasper-dev \
libgtk2.0-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libjasper-dev \
libv4l-dev \
&& \
apt-get clean && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/*
# Define default command.
CMD ["python", "--version"]