-
Notifications
You must be signed in to change notification settings - Fork 1
/
ssd_dockerfile_ubi8
436 lines (370 loc) · 10.8 KB
/
ssd_dockerfile_ubi8
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# mlcc -i RHEL8.1,CUDA10.2.min,Numpy
# mlcc version: 20181224a: Nov 12 2019
# Install RHEL-UBI-8.1 backed by lower priority RHEL8 repos
FROM registry.access.redhat.com/ubi8:8.1
RUN set -vx \
\
&& yum -y -v install yum-utils \
&& yum-config-manager --enable \
rhel-8-for-x86_64-baseos-rpms \
rhel-8-for-x86_64-appstream-rpms \
rhel-8-for-x86_64-supplementary-rpms \
\
&& sed -i '/enabled = 1/ a priority = 1' /etc/yum.repos.d/ubi.repo \
&& sed -i '/enabled = 1/ a priority = 99' /etc/yum.repos.d/redhat.repo \
\
&& yum -y -v install "https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm" \
\
&& yum clean all \
&& yum -y update \
\
&& cd /var/cache \
&& /bin/rm -rf dnf yum
# Install Basic OS Tools
RUN set -vx \
\
&& echo -e '\
set -vx \n\
for (( TRY=1; TRY<=11; TRY++ )); do \n\
yum -y -v install $@ \n\
result=$? \n\
for PKG in $@ ; do \n\
yum list installed | grep "^$PKG" \n\
(( result += $? )) \n\
done \n\
if (( $result == 0 )); then \n\
/bin/rm -rf /var/cache/yum \n\
/bin/rm -rf /var/cache/dnf \n\
exit 0 \n\
fi \n\
sleep 10 \n\
done \n\
exit 1 \n' \
> /tmp/yum_install.sh \
\
&& chmod +x /tmp/yum_install.sh \
\
&& cd /usr/local \
&& /bin/rm -rf lib64 \
&& ln -s lib lib64 \
\
&& /tmp/yum_install.sh \
binutils \
bzip2 \
findutils \
gcc \
gcc-c++ \
gcc-gfortran \
git \
gzip \
make \
openssl-devel \
patch \
pciutils \
unzip \
vim-enhanced \
wget \
xz \
zip
# Install Python v3.8.2, if no python3 already present
RUN set -vx \
\
&& if whereis python3 | grep -q "python3.." ; then \
\
if yum info python3-devel > /dev/null 2>&1; then \
PYTHON3_DEVEL="python3-devel"; \
else \
PYTHON3_DEVEL="python3[0-9]-devel"; \
fi; \
\
/tmp/yum_install.sh python3 python3-pip ${PYTHON3_DEVEL} python3-setuptools; \
\
ln -s /usr/bin/python3 /usr/local/bin/python3; \
ln -s /usr/bin/pip3 /usr/local/bin/pip3; \
for d in /usr/lib/python3*; do PYLIBDIR="$d"; echo 'PYLIBDIR: ' $PYLIBDIR; done; \
ln -s $PYLIBDIR /usr/local/lib/`basename $PYLIBDIR`; \
for d in /usr/include/python3*; do PYINCDIR="$d"; echo 'PYINCDIR: ' $PYINCDIR; done; \
ln -s $PYINCDIR /usr/local/include/`basename $PYINCDIR`; \
\
else \
\
/tmp/yum_install.sh \
bzip2-devel \
expat-devel \
gdbm-devel \
libdb4-devel \
libffi-devel \
ncurses-devel \
openssl-devel \
readline-devel \
sqlite-devel \
tk-devel \
xz-devel \
zlib-devel; \
cd /var/cache; \
/bin/rm -rf dnf yum; \
\
cd /tmp; \
wget "https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz"; \
tar -xf Python*.xz; \
/bin/rm Python*.xz; \
cd /tmp/Python*; \
./configure \
--enable-optimizations \
--enable-shared \
--prefix=/usr/local \
--with-ensurepip=install \
LDFLAGS="-Wl,-rpath /usr/local/lib"; \
make -j`getconf _NPROCESSORS_ONLN` install; \
\
cd /tmp; \
/bin/rm -r /tmp/Python*; \
\
fi \
\
&& cd /usr/local/include \
&& PYTHON_INC_DIR_NAME=`ls -d ./python*` \
&& ALT_PYTHON_INC_DIR_NAME=${PYTHON_INC_DIR_NAME%m} \
&& if [ "$ALT_PYTHON_INC_DIR_NAME" != "$PYTHON_INC_DIR_NAME" ]; then \
ln -s "$PYTHON_INC_DIR_NAME" "$ALT_PYTHON_INC_DIR_NAME"; \
fi \
\
&& /usr/local/bin/pip3 -v install --upgrade \
pip \
setuptools \
\
&& if python --version > /dev/null 2>&1; then \
whereis python; \
python --version; \
else \
cd /usr/bin; \
ln -s python3 python; \
cd /usr/local/bin; \
ln -s python3 python; \
fi \
\
&& /bin/ls -RFCa /usr/local/include/python*
# Install CMake v3.17.0
RUN set -vx \
\
&& cd /tmp \
&& wget "https://cmake.org/files/v3.17/cmake-3.17.0.tar.gz" \
&& tar -xf cmake*.gz \
&& /bin/rm cmake*.gz \
&& cd /tmp/cmake* \
&& ./bootstrap \
&& make -j`getconf _NPROCESSORS_ONLN` install \
&& cd /tmp \
&& /bin/rm -rf /tmp/cmake* \
&& cmake --version
RUN date; df -h
# Install minimal subsets of CUDA 10.2
RUN set -vx \
\
&& echo -e '\
exec > /etc/yum.repos.d/cuda.repo \n\
echo [cuda] \n\
echo name=cuda \n\
if [ "`/bin/arch`" = "aarch64" ]; then \n\
echo baseurl="file:///var/cuda-repo" \n\
elif [ -f /etc/fedora-release ]; then \n\
echo baseurl="http://developer.download.nvidia.com/compute/cuda/repos/fedora29/`/bin/arch`" \n\
else \n\
OS_MAJ_VER=`(. /etc/os-release; echo ${VERSION_ID:0:1})` \n\
echo baseurl="http://developer.download.nvidia.com/compute/cuda/repos/rhel${OS_MAJ_VER}/`/bin/arch`" \n\
fi \n\
echo enabled=1 \n\
echo gpgcheck=0 \n' \
>> /tmp/Make_CUDA_Repo.sh \
&& sh /tmp/Make_CUDA_Repo.sh \
\
&& /tmp/yum_install.sh \
cuda-libraries-10-2 \
cuda-libraries-dev-10-2 \
cuda-command-line-tools-10-2 \
&& ln -s /usr/local/cuda-10.2 /usr/local/cuda
ENV \
CUDA_VERSION="10.2" \
CUDA_HOME="/usr/local/cuda" \
CUDA_PATH="/usr/local/cuda" \
PATH="/usr/local/cuda/bin:/usr/local/bin:/usr/bin:${PATH:+:${PATH}}" \
LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
# Install old GCC v8.3 if necessary
RUN set -vx \
\
&& GCC_VERSION_OUTPUT=`gcc --version` \
&& if [ "${GCC_VERSION_OUTPUT:10:1}" -gt 8 ]; then \
\
mkdir -p /tmp/gcc_tmp_build_dir; \
cd /tmp/gcc_tmp_build_dir; \
\
wget -q "https://ftp.gnu.org/gnu/gcc/gcc-8.3.0/gcc-8.3.0.tar.xz"; \
wget -q "https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2"; \
wget -q "https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2"; \
wget -q "https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz"; \
wget -q "https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2"; \
\
tar -xf gcc-8.3.0.tar.xz; \
tar -xf gmp-6.1.0.tar.bz2; \
tar -xf mpfr-3.1.4.tar.bz2; \
tar -xf mpc-1.0.3.tar.gz; \
tar -xf isl-0.18.tar.bz2; \
\
ln -s /tmp/gcc_tmp_build_dir/gmp-6.1.0 gcc-8.3.0/gmp; \
ln -s /tmp/gcc_tmp_build_dir/mpfr-3.1.4 gcc-8.3.0/mpfr; \
ln -s /tmp/gcc_tmp_build_dir/mpc-1.0.3 gcc-8.3.0/mpc; \
ln -s /tmp/gcc_tmp_build_dir/isl-0.18 gcc-8.3.0/isl; \
\
gcc-8.3.0/configure --disable-multilib --enable-languages=c,c++,fortran --prefix=/usr/local; \
make -j`getconf _NPROCESSORS_ONLN`; \
make install-strip; \
\
cd /tmp; \
/bin/rm -rf /tmp/gcc_tmp_build_dir; \
\
ln -s /usr/local/bin/gcc /usr/local/cuda/bin/gcc; \
ln -s /usr/local/bin/g++ /usr/local/cuda/bin/g++; \
export CC="/usr/local/bin/gcc"; \
export CXX="/usr/local/bin/g++"; \
\
echo -e '\
\n\
export CC="/usr/local/bin/gcc" \n\
export CXX="/usr/local/bin/g++" \n\
\n' \
>> ~/.bashrc; \
\
fi
# Install NVIDIA NCCL
# See: https://developer.nvidia.com/nccl
RUN set -vx \
\
&& cd /tmp \
&& git clone --depth 1 "https://github.com/NVIDIA/nccl.git" \
&& cd /tmp/nccl \
\
&& if grep install Makefile ; then \
echo "Makefile already has install target"; \
else \
echo "install: src.install" >> Makefile; \
fi \
\
&& make -j`getconf _NPROCESSORS_ONLN` src.build \
&& make -j`getconf _NPROCESSORS_ONLN` install \
\
&& cd /tmp \
&& /bin/rm -rf /tmp/nccl* \
\
&& ldconfig
# Install NVIDIA cuDNN
# See: https://developer.nvidia.com/cudnn
RUN set -vx \
\
&& cd /tmp \
\
&& echo -e '\
set -vx \n\
if [ -d "/usr/local/cuda-10.2" ]; then \n\
CUDNN_VER="v7.6.5/cudnn-10.2-linux-x64-v7.6.5.32.tgz" \n\
elif [ -d "/usr/local/cuda-10.1" ]; then \n\
CUDNN_VER="v7.5.0/cudnn-10.1-linux-x64-v7.5.0.56.tgz" \n\
CUDNN_VER="v7.6.5/cudnn-10.1-linux-x64-v7.6.5.32.tgz" \n\
elif [ -d "/usr/local/cuda-10.0" ]; then \n\
CUDNN_VER="v7.5.0/cudnn-10.0-linux-x64-v7.5.0.56.tgz" \n\
CUDNN_VER="v7.6.5/cudnn-10.0-linux-x64-v7.6.5.32.tgz" \n\
elif [ -d "/usr/local/cuda-9.2" ]; then \n\
CUDNN_VER="v7.5.0/cudnn-9.2-linux-x64-v7.5.0.56.tgz" \n\
CUDNN_VER="v7.6.5/cudnn-9.2-linux-x64-v7.6.5.32.tgz" \n\
elif [ -d "/usr/local/cuda-9.1" ]; then \n\
CUDNN_VER="v7.1.3/cudnn-9.1-linux-x64-v7.1.tgz" \n\
elif [ -d "/usr/local/cuda-9.0" ]; then \n\
CUDNN_VER="v7.5.0/cudnn-9.0-linux-x64-v7.5.0.56.tgz" \n\
CUDNN_VER="v7.6.5/cudnn-9.0-linux-x64-v7.6.5.32.tgz" \n\
elif [ -d "/usr/local/cuda-8.0" ]; then \n\
CUDNN_VER="v7.1.3/cudnn-8.0-linux-x64-v7.1.tgz" \n\
else \n\
CUDNN_VER="idk_cudnn_version" \n\
fi \n\
echo "http://developer.download.nvidia.com/compute/redist/cudnn/$CUDNN_VER" \n' \
> /tmp/select_cudnn.sh \
\
&& if [ "`/bin/arch`" = "x86_64" ]; then \
\
wget `sh /tmp/select_cudnn.sh` \
\
&& tar -xvf cudnn*.tgz \
&& cd /tmp/cuda \
\
&& mv include/cudnn.h /usr/local/cuda/include \
&& mv lib64/lib* /usr/local/cuda/lib64 \
\
&& cd /tmp \
&& /bin/rm -rf /tmp/cud* \
\
&& ldconfig; \
\
fi
RUN date; df -h
# Install Numpy
RUN set -vx \
\
&& /usr/local/bin/pip3 -v install \
numpy \
\
&& /usr/local/bin/python3 -c 'import numpy'
RUN date; df -h
# Build PyTorch from NGC code
RUN pip3 install tqdm pyyaml
WORKDIR /opt/pytorch
COPY pytorch .
WORKDIR /opt/pytorch/pytorch
ENV PYTORCH_BUILD_VERSION=1.1.0a0+828a6a3 PYTORCH_VERSION=1.1.0a0+828a6a3 PYTORCH_BUILD_NUMBER=0
RUN python3 setup.py install \
&& cp -a /opt/pytorch/pytorch/third_party/ideep/mkl-dnn/external/mklml_lnx*/lib/* /usr/lib64 \
&& python3 setup.py clean \
&& rm -rf /opt/pytorch/pytorch/build
RUN pip3 install pillow==6.2.1
WORKDIR /opt/pytorch/vision
RUN python3 setup.py install \
&& python3 setup.py clean
#Install NVIDIA apex
WORKDIR /opt/pytorch/apex
RUN rm -rf build \
&& python3 setup.py install --cuda_ext --cpp_ext --bnp
# Install NVIDIA DALI
RUN pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/cuda/10.0 nvidia-dali==0.12.0
# Install COCO API
WORKDIR /opt
ENV COCOAPI_VERSION=2.0+nv0.3.1
RUN pip3 install pybind11
ENV C_INCLUDE_PATH=/usr/local/include/python3.6m/
ENV CPLUS_INCLUDE_PATH=/usr/local/include/python3.6m/
ENV COCOAPI_VERSION=2.0+nv0.3.1
#RUN export COCOAPI_TAG=$(echo ${COCOAPI_VERSION} | sed 's/^.*+n//') \
#&& pip3 install --verbose --no-cache-dir git+https://github.com/nvidia/cocoapi.git@${COCOAPI_TAG}#subdirectory=PythonAPI
RUN pip3 install --no-cache-dir git+https://github.com/dagrayvid/cocoapi.git@fix_vector_assertion#subdirectory=PythonAPI
# install numactl
RUN yum -y install numactl \
infiniband-diags \
pciutils
ENV NVIDIA_PYTORCH_VERSION="RHEL"
ENV OPENMPI_VERSION=3.1.2
ENV CUDA_DRIVER_VERSION=418.67
ENV NCCL_VERSION=2.3.7
ENV CUDNN_VERSION=7.4
ENV CUBLAS_VERSION=10.0.130
ENV TRT_VERSION=none
ENV DALI_VERSION=none
# Install Python dependencies
WORKDIR /workspace/single_stage_detector
COPY ssd/requirements.txt .
RUN pip3 install --no-cache-dir https://github.com/mlperf/training/archive/6289993e1e9f0f5c4534336df83ff199bd0cdb75.zip#subdirectory=compliance \
&& pip3 install --no-cache-dir -r requirements.txt
RUN dnf -y install openmpi
# Copy SSD code and build
COPY ssd .
RUN pip3 install .
RUN rm -rf ./pytorch
# Configure environment variables
ENV OMP_NUM_THREADS=1
ENV OPENCV_FOR_THREADS_NUM=1