-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.gpu
271 lines (217 loc) · 7.31 KB
/
Dockerfile.gpu
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
From nvidia/cuda:11.4.2-cudnn8-devel-ubuntu20.04
# FROM base as base-amd64
ENV NV_CUDNN_VERSION 8.2.4.15
ENV NV_CUDNN_PACKAGE "libcudnn8=$NV_CUDNN_VERSION-1+cuda11.4"
ENV NV_CUDNN_PACKAGE_DEV "libcudnn8-dev=$NV_CUDNN_VERSION-1+cuda11.4"
ENV NV_CUDNN_PACKAGE_NAME "libcudnn8"
# FROM base-${TARGETARCH}
ARG TARGETARCH
LABEL maintainer "Ammar Yasir Naich <[email protected]>"
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
RUN apt-get update && apt-get install -y --no-install-recommends \
${NV_CUDNN_PACKAGE} \
${NV_CUDNN_PACKAGE_DEV} \
&& apt-mark hold ${NV_CUDNN_PACKAGE_NAME} && \
rm -rf /var/lib/apt/lists/*
# Needed for string substitution
SHELL ["/bin/bash", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
ARG PYTHON_VERSION=3.8
ARG OPENCV_VERSION=4.5.0
COPY gpu_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 &&\
apt-get -y install openexr \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION%%.*}-distutils" ) \
git\
gnupg2\
ca-certificates \
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 \
libopencv-dev \
libboost-all-dev \
python3-dev
# 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 -r gpu_requirements.txt
# Opening port for jupyter
EXPOSE 8888
# Opening port for Tensorboard
EXPOSE 6006
# Tensorflow Current stable release for CPU and GPU and Keras
#RUN pip${PYTHON_VERSION} install tensorflow keras mxnet-cu102 optuna cupy-cuda111 chainer theano
#cntk-gpu
# Opening port for Tensorboard
EXPOSE 6006
## install pytoch
RUN pip${PYTHON_VERSION} install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -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_CUDA=ON \
-D WITH_LAPACK=ON \
#-D WITH_HPX=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
# https://kezunlin.me/post/6580691f
# https://stackoverflow.com/questions/28010399/build-opencv-with-cuda-support
-D CUDA_ARCH_BIN="5.3 6.1 7.0 7.5" \
-D CUDA_ARCH_PTX="" \
-D WITH_CUBLAS=ON \
-D WITH_NVCUVID=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
.. \
&& \
# Build, Test and Install
cd /opencv/build && \
make -j$(nproc) && \
make install && \
ldconfig
################# darknet
# build darknet
WORKDIR /app
RUN git clone https://github.com/AlexeyAB/darknet.git
WORKDIR darknet
RUN make OPENCV=1 GPU=1 AVX=1 OPENMP=1 CUDNN=1 CUDNN_HALF=1 OPENMP=1 -j $(nproc)
RUN chmod +x darknet
# Set the default python and install PIP packages
RUN 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__)"
#cleaning
RUN apt-get -y remove \
unzip \
cmake \
gfortran \
apt-utils \
pkg-config \
checkinstall \
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 \
&& \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* ~/* \
&& \
rm -rf /opencv /opencv_contrib /var/lib/apt/lists/*
RUN apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* ~/*
WORKDIR "/root/"
#ENTRYPOINT ["/bin/bash"]
CMD ["jupyter","notebook","--port=8888","--ip=0.0.0.0","--allow-root","--no-browser"]