-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.cpu
214 lines (182 loc) · 5.84 KB
/
Dockerfile.cpu
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
FROM ubuntu:20.04
MAINTAINER "Ammar Yasir Niach email:[email protected]"
ARG PYTHON_VERSION=3.8
ARG OPENCV_VERSION=4.5.0
# Needed for string substitution
SHELL ["/bin/bash", "-c"]
# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
COPY cpu_requirements.txt ./
# add sources for older pythons
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
# Install all dependencies for OpenCV
apt-get -y update -qq --fix-missing && \
apt-get -y install --no-install-recommends \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION%%.*}-distutils" ) \
wget \
unzip \
cmake \
ffmpeg \
libtbb2 \
gfortran \
apt-utils \
pkg-config \
checkinstall \
qt5-default \
build-essential \
libopenblas-base \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
#libgtk-3-dev \
#libavcodec58 \
libavcodec-dev \
#libavformat58 \
libavformat-dev \
libavutil-dev \
#libswscale5 \
libswscale-dev \
libjpeg8-dev \
libpng-dev \
libtiff5-dev \
#libdc1394-22 \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libgstreamer1.0 \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-0 \
libgstreamer-plugins-base1.0-dev \
libglew-dev \
libpostproc-dev \
libeigen3-dev \
libtbb-dev \
zlib1g-dev \
libsm6 \
libxext6 \
libxrender1
# install python dependencies
# sysctl -w net.ipv4.ip_forward=1 && \
RUN wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll && \
python${PYTHON_VERSION} get-pip.py && \
rm get-pip.py && \
pip${PYTHON_VERSION} install numpy==1.19.4 \
pandas==1.1.5 \
scikit-learn==0.23.2\
matplotlib==3.3.3 \
seaborn==0.11.1 \
pyyaml==5.3.1 \
#h5py==3.1.0\
tensorflow==2.4.0\
keras==2.4.3 \
mxnet \
chainer \
theano==1.0.5 \
jupyterlab \
nltk==3.5
EXPOSE 8888
# Opening port for Tensorboard
EXPOSE 6006
## install pytoch
RUN pip${PYTHON_VERSION} install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
#Java
#
# Install JDK (Java Development Kit), which includes JRE (Java Runtime
# Environment). Or, if you just want to run Java apps, you can install
# JRE only using: apt install default-jre
RUN apt-get install -y --no-install-recommends default-jdk
# Install OpenCV
RUN wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -O opencv.zip --progress=bar:force:noscroll && \
unzip -q opencv.zip && \
mv /opencv-$OPENCV_VERSION /opencv && \
rm opencv.zip && \
wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip -O opencv_contrib.zip --progress=bar:force:noscroll && \
unzip -q opencv_contrib.zip && \
mv /opencv_contrib-$OPENCV_VERSION /opencv_contrib && \
rm opencv_contrib.zip && \
# Prepare build
mkdir /opencv/build && \
cd /opencv/build && \
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_PYTHON_SUPPORT=ON \
-D BUILD_DOCS=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
-D BUILD_opencv_python3=$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "ON" || echo "OFF" ) \
-D BUILD_opencv_python2=$( [ ${PYTHON_VERSION%%.*} -lt 3 ] && echo "ON" || echo "OFF" ) \
-D PYTHON${PYTHON_VERSION%%.*}_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
-D BUILD_EXAMPLES=OFF \
-D WITH_IPP=OFF \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_TBB=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D WITH_LAPACK=ON \
#-D WITH_HPX=ON \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
.. \
&& \
# Build, Test and Install
cd /opencv/build && \
make -j$(nproc) && \
make install && \
ldconfig && \
# cleaning
apt-get -y remove \
unzip \
cmake \
gfortran \
apt-utils \
pkg-config \
checkinstall \
build-essential \
libopenblas-dev \
liblapack-dev \
libatlas-base-dev \
#libgtk-3-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswscale-dev \
libjpeg8-dev \
libpng12-dev \
libtiff5-dev \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libglew-dev \
libpostproc-dev \
libeigen3-dev \
libtbb-dev \
zlib1g-dev \
&& \
### cleanup
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* ~/* && \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/* && \
# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
# Call default command.
ffmpeg -version && \
#ldd `which ffmpeg` && \
python --version && \
python -c "import cv2 ; print(cv2.__version__)"
WORKDIR "/root/"
#ENTRYPOINT ["/bin/bash"]
CMD ["jupyter","notebook","--port=8888","--ip=0.0.0.0","--allow-root","--no-browser"]