1
+ FROM nvidia/cuda:10.1-devel-ubuntu18.04
2
+
3
+ # TensorFlow version is tightly coupled to CUDA and cuDNN so it should be selected carefully
4
+ ARG CUDA=10.1
5
+ ARG LIBNVINFER=6.0.1-1
6
+ ARG LIBNVINFER_MAJOR_VERSION=6
7
+ ARG CUDNN=7.6.4.38-1
8
+ ENV CUDNN_VERSION=7.6.4.38-1+cuda10.1
9
+ ENV NCCL_VERSION=2.4.8-1+cuda10.1
10
+ ENV DEBIAN_FRONTEND=noninteractive
11
+ ENV mecab_dicdir /usr/local/lib/mecab/dic/mecab-ko-dic
12
+
13
+ # Python 2.7 or 3.67 is supported by Ubuntu Bionic out of the box
14
+ ARG python=3.6
15
+ ENV PYTHON_VERSION=${python}
16
+
17
+ ENV PYTHONUNBUFFERED=1 \
18
+ LD_LIBRARY_PATH="/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/nvidia/lib64:/usr/local/cuda/lib64/stubs:/usr/include/x86_64-linux-gnu" \
19
+ PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin/mecab" \
20
+ LANG=C.UTF-8
21
+
22
+ # Set default shell to /bin/bash
23
+ SHELL ["/bin/bash" , "-cu" ]
24
+
25
+ RUN apt-get update -y && \
26
+ apt-get install -y --no-install-recommends software-properties-common && \
27
+ add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" && \
28
+ apt-get update -y && \
29
+ apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
30
+ build-essential \
31
+ ca-certificates \
32
+ gcc g++ make \
33
+ gfortran \
34
+ dkms \
35
+ git \
36
+ curl \
37
+ vim \
38
+ yasm \
39
+ wget zip unzip \
40
+ ca-certificates \
41
+ software-properties-common \
42
+ openssh-client openssh-server \
43
+ libssl-dev \
44
+ libmpdec2 \
45
+ pdsh curl sudo net-tools \
46
+ iputils-ping \
47
+ cuda-command-line-tools-${CUDA/./-} \
48
+ libcublas10=10.2.1.243-1 \
49
+ libcublas-dev=10.2.1.243-1 \
50
+ cuda-nvrtc-${CUDA/./-} \
51
+ cuda-nvrtc-dev-${CUDA/./-} \
52
+ cuda-cudart-dev-${CUDA/./-} \
53
+ cuda-cufft-dev-${CUDA/./-} \
54
+ cuda-curand-dev-${CUDA/./-} \
55
+ cuda-cusolver-dev-${CUDA/./-} \
56
+ cuda-cusparse-dev-${CUDA/./-} \
57
+ libcudnn7=${CUDNN_VERSION} \
58
+ libcudnn7-dev=${CUDNN}+cuda${CUDA} \
59
+ libnccl2=${NCCL_VERSION} \
60
+ libnccl-dev=${NCCL_VERSION} \
61
+ libcurl3-dev \
62
+ libfreetype6-dev \
63
+ libhdf5-serial-dev \
64
+ libzmq3-dev \
65
+ libjpeg-dev \
66
+ libpng-dev \
67
+ libsm6 \
68
+ libxext6 \
69
+ libxrender-dev \
70
+ libcairo2-dev libgirepository1.0-dev pkg-config gir1.2-gtk-3.0 \
71
+ libgeos-dev libgeos++-dev \
72
+ pkg-config \
73
+ zlib1g-dev \
74
+ mime-support \
75
+ proj-bin libproj-dev libgeos-dev libgeos++-dev graphviz \
76
+ python${PYTHON_VERSION} \
77
+ python${PYTHON_VERSION}-dev \
78
+ libnuma-dev \
79
+ libjasper-dev \
80
+ libtiff-dev \
81
+ libavcodec-dev \
82
+ libavformat-dev \
83
+ libswscale-dev \
84
+ libxine2-dev \
85
+ libv4l-dev \
86
+ libboost-dev \
87
+ libboost-system-dev \
88
+ libboost-filesystem-dev \
89
+ fonts-nanum \
90
+ fonts-nanum-coding \
91
+ fonts-nanum-extra
92
+ RUN find /usr/local/cuda-${CUDA}/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \
93
+ rm /usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a
94
+
95
+ RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 \
96
+ && echo "/usr/local/cuda/lib64/stubs" > /etc/ld.so.conf.d/z-cuda-stubs.conf \
97
+ && ldconfig
98
+
99
+ RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
100
+ apt-get update -y && \
101
+ apt-get install -y nodejs
102
+
103
+ RUN apt-get update && \
104
+ apt-get install -y --no-install-recommends libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
105
+ libnvinfer-dev=${LIBNVINFER}+cuda${CUDA} \
106
+ libnvinfer-plugin-dev=${LIBNVINFER}+cuda${CUDA} \
107
+ libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
108
+ && apt-get clean \
109
+ && rm -rf /var/lib/apt/lists/*
110
+
111
+ # OFED
112
+ ENV STAGE_DIR=/tmp
113
+ RUN mkdir -p ${STAGE_DIR}
114
+ ENV MLNX_OFED_VERSION=4.6-1.0.1.1
115
+ RUN cd ${STAGE_DIR} && \
116
+ wget -q -O - http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_OFED_VERSION}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64.tgz | tar xzf -
117
+ RUN cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
118
+ ./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
119
+ cd ${STAGE_DIR} && \
120
+ rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
121
+
122
+ # nvidia-peer
123
+ RUN mkdir -p ${STAGE_DIR} && \
124
+ git clone https://github.com/Mellanox/nv_peer_memory.git ${STAGE_DIR}/nv_peer_memory && \
125
+ cd ${STAGE_DIR}/nv_peer_memory && \
126
+ ./build_module.sh && \
127
+ cd ${STAGE_DIR} && \
128
+ tar xzf ${STAGE_DIR}/nvidia-peer-memory_1.0.orig.tar.gz && \
129
+ cd ${STAGE_DIR}/nvidia-peer-memory-1.0 && \
130
+ dpkg-buildpackage -us -uc && \
131
+ dpkg -i ${STAGE_DIR}/nvidia-peer-memory_1.0-8_all.deb
132
+
133
+ # Install CUDA-10.1 + cuDNN 7.6.0
134
+ RUN ln -s /usr/local/cuda-10.1 /usr/local/cuda && \
135
+ ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.0 /usr/local/cuda/lib64/libcudnn.so && \
136
+ ldconfig
137
+
138
+ RUN if [[ "${PYTHON_VERSION}" == "3.6" ]]; then \
139
+ apt-get install -y python${PYTHON_VERSION}-distutils python-apt ; \
140
+ fi
141
+
142
+ RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2
143
+
144
+ WORKDIR /tmp
145
+ RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \
146
+ python3 -m pip install --no-cache-dir -U setuptools pip
147
+
148
+ # Install TensorFlow, Keras, PyTorch and MXNet
149
+ RUN python3 -m pip install pip --no-cache-dir -Iv \
150
+ Cython==0.29.13 \
151
+ numpy==1.16.3 \
152
+ scipy==1.4.1 \
153
+ scikit-image==0.16.2 \
154
+ scikit-learn==0.22.2 \
155
+ tornado==6.0.4 \
156
+ pystan==2.19.1.1 \
157
+ pycairo==1.19.0 \
158
+ matplotlib==3.1.3
159
+ RUN python3 -m pip install pip --no-cache-dir \
160
+ Cartopy==0.17.0 \
161
+ notebook==6.0.3
162
+
163
+ WORKDIR /tmp
164
+ COPY ./requirements.20.03.txt /tmp
165
+ RUN python3 -m pip install --no-cache-dir -Ir requirements.20.03.txt
166
+
167
+ ENV PYTORCH_VERSION=1.3.1
168
+ ENV TORCHVISION_VERSION=0.4.2
169
+ ENV TORCHAUDIO_VERSION=0.3.2
170
+ ENV TORCHTEXT_VERSION=0.5.0
171
+ ENV TENSORBOARDX_VERSION=1.9
172
+
173
+ RUN python3 -m pip install pip --no-cache-dir \
174
+ pandas==1.0.1 \
175
+ https://download.pytorch.org/whl/cu101/torch-${PYTORCH_VERSION}-cp36-cp36m-linux_x86_64.whl \
176
+ https://download.pytorch.org/whl/cu101/torchvision-${TORCHVISION_VERSION}-cp36-cp36m-linux_x86_64.whl \
177
+ https://download.pytorch.org/whl/torchaudio-${TORCHAUDIO_VERSION}-cp36-cp36m-manylinux1_x86_64.whl \
178
+ torchtext==${TORCHTEXT_VERSION} && \
179
+ python3 -m pip install --no-cache-dir tensorboardX==${TENSORBOARDX_VERSION}
180
+ RUN python3 -m pip install --no-cache-dir --extra-index-url \
181
+ https://developer.download.nvidia.com/compute/redist/cuda/10.0 \
182
+ nvidia-dali
183
+
184
+ RUN python3 -m pip install --no-cache-dir -Iv \
185
+ konlpy h5py && \
186
+ rm -f /tmp/*.whl /tmp/requirements.20.03.txt
187
+
188
+ RUN apt-get update && \
189
+ apt-get install -y \
190
+ openjdk-8-jdk \
191
+ automake \
192
+ && \
193
+ cd /tmp && \
194
+ curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
195
+ tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
196
+ cd mecab-0.996-ko-0.9.2 && \
197
+ ./configure && \
198
+ make -j$(nproc) && \
199
+ make check && \
200
+ make install
201
+
202
+ RUN echo "Install mecab-ko-dic" && \
203
+ cd /tmp && \
204
+ ldconfig && \
205
+ curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
206
+ tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
207
+ cd mecab-ko-dic-2.1.1-20180720 && \
208
+ ./autogen.sh && \
209
+ ./configure && \
210
+ make -j$(nproc) && \
211
+ sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \
212
+ make install && \
213
+ cd /tmp && \
214
+ git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
215
+ python3 -m pip install /tmp/mecab-python-0.996
216
+
217
+ RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
218
+ apt-get install -y \
219
+ libgstreamer1.0-dev \
220
+ libgstreamer-plugins-base1.0-dev \
221
+ libgtk-3-dev \
222
+ libtbb-dev \
223
+ libatlas-base-dev \
224
+ libdc1394-22-dev \
225
+ libxvidcore-dev \
226
+ libfaac-dev \
227
+ libmp3lame-dev \
228
+ libtheora-dev \
229
+ libvorbis-dev \
230
+ libxvidcore-dev \
231
+ libopencore-amrnb-dev libopencore-amrwb-dev \
232
+ libavresample-dev \
233
+ x264 \
234
+ libx264-dev \
235
+ v4l-utils \
236
+ libprotobuf-dev protobuf-compiler \
237
+ libgoogle-glog-dev libgflags-dev \
238
+ libgphoto2-dev \
239
+ libeigen3-dev \
240
+ libhdf5-dev \
241
+ && \
242
+ apt-get clean && \
243
+ rm -rf /var/lib/apt/lists/
244
+
245
+ RUN wget https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.sh \
246
+ -q -O /tmp/cmake-install.sh && \
247
+ chmod u+x /tmp/cmake-install.sh && \
248
+ mkdir /usr/bin/cmake && \
249
+ /tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake && \
250
+ rm /tmp/cmake-install.sh
251
+
252
+ ENV PATH="/usr/bin/cmake/bin:${PATH}"
253
+
254
+ WORKDIR /tmp
255
+ ENV OPENCV_VERSION="4.1.0"
256
+ RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
257
+ wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
258
+ unzip ${OPENCV_VERSION}.zip && \
259
+ unzip opencv-contrib.zip && \
260
+ mkdir opencv-${OPENCV_VERSION}/cmake_binary && \
261
+ cd opencv-${OPENCV_VERSION}/cmake_binary && \
262
+ cmake \
263
+ -DCMAKE_BUILD_TYPE=RELEASE \
264
+ -D BUILD_TIFF=ON \
265
+ -D BUILD_opencv_java=OFF \
266
+ -D WITH_CUDA=ON \
267
+ -D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
268
+ -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.1 \
269
+ -D ENABLE_FAST_MATH=1 \
270
+ -D CUDA_FAST_MATH=1 \
271
+ -D WITH_CUBLAS=1 \
272
+ -D WITH_OPENGL=ON \
273
+ -D WITH_OPENCL=ON \
274
+ -D WITH_IPP=ON \
275
+ -D WITH_TBB=ON \
276
+ -D WITH_EIGEN=ON \
277
+ -D WITH_V4L=ON \
278
+ -D BUILD_TESTS=OFF \
279
+ -D BUILD_PERF_TESTS=OFF \
280
+ -D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.1.0/modules" \
281
+ -D CMAKE_BUILD_TYPE=RELEASE \
282
+ -D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)" ) \
283
+ -D PYTHON_EXECUTABLE=$(which python3) \
284
+ -D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())" ) \
285
+ -D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" ) \
286
+ .. 2>&1 | tee cmake_messages.txt && \
287
+ make -j$(nproc) && \
288
+ make install && \
289
+ cd /tmp && \
290
+ rm -fr opencv*
291
+
292
+ RUN python3 -m pip install --no-cache-dir opencv-python && \
293
+ rm -rf /root/.cache
294
+
295
+ # add 19.09.06
296
+ RUN git clone --recursive https://github.com/dmlc/xgboost && \
297
+ cd xgboost && \
298
+ mkdir build && \
299
+ cd build && \
300
+ cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON && \
301
+ make -j$(nproc) && \
302
+ cd ../python-package && \
303
+ python3 setup.py install
304
+
305
+ RUN git clone --recursive https://github.com/Microsoft/LightGBM && \
306
+ cd LightGBM && \
307
+ mkdir build ; cd build && \
308
+ cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda-10.1/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda-10.1/include/ .. && \
309
+ make -j$(nproc) && \
310
+ cd ../python-package && \
311
+ python3 setup.py install --precompile
312
+
313
+ # Install Open MPI
314
+ RUN mkdir /tmp/openmpi && \
315
+ cd /tmp/openmpi && \
316
+ wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.1.tar.gz && \
317
+ tar zxf openmpi-4.0.1.tar.gz && \
318
+ cd openmpi-4.0.1 && \
319
+ ./configure --enable-orterun-prefix-by-default && \
320
+ make -j $(nproc) all && \
321
+ make install && \
322
+ ldconfig && \
323
+ rm -rf /tmp/openmp*i
324
+
325
+ # Install Horovod, temporarily using CUDA stubs
326
+ RUN ldconfig /usr/local/cuda/targets/x86_64-linux/lib/stubs && \
327
+ HOROVOD_GPU_ALLREDUCE=NCCL HOROVOD_GPU_BROADCAST=NCCL \
328
+ HOROVOD_WITHOUT_TENSORFLOW=1 HOROVOD_WITH_PYTORCH=1 HOROVOD_WITHOUT_MXNET=1 \
329
+ pip install --no-cache-dir horovod==0.19.0 && \
330
+ ldconfig
331
+
332
+ RUN python3 -m pip install --no-cache-dir \
333
+ mpi4py==3.0.3 \
334
+ nni && \
335
+ rm -rf /root/.cache && \
336
+ rm -rf /tmp/*
337
+
338
+ # Install OpenSSH for MPI to communicate between containers
339
+ RUN apt-get install -y --no-install-recommends openssh-client openssh-server && \
340
+ mkdir -p /var/run/sshd
341
+
342
+ # Allow OpenSSH to talk to containers without asking for confirmation
343
+ RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
344
+ echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
345
+ mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
346
+
347
+ # Install ipython kernelspec
348
+ Run python3 -m ipykernel install --display-name "PyTorch 1.3 on Python 3.6 (CUDA 10.1)" && \
349
+ cat /usr/local/share/jupyter/kernels/python3/kernel.json
350
+
351
+ # Jupyter notebook extension
352
+ RUN mkdir -p /home/work/.jupyter/nbextension
353
+ WORKDIR /home/work/.jupyter/nbextension
354
+
355
+ RUN jupyter nbextensions_configurator enable && \
356
+ jupyter contrib nbextension install && \
357
+ jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
358
+ jupyter contrib nbextension install && \
359
+ jupyter serverextension enable --py jupyterlab --sys-prefix && \
360
+ jupyter labextension install @jupyter-widgets/jupyterlab-manager && \
361
+ git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding && \
362
+ jupyter nbextension enable /home/work/.jupyter/nbextension/vim_binding/vim_binding
363
+
364
+ # Backend.AI specifics
365
+ LABEL ai.backend.kernelspec="1" \
366
+ ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
367
+ ai.backend.features="batch query uid-match user-input" \
368
+ ai.backend.base-distro="ubuntu16.04" \
369
+ ai.backend.resource.min.cpu="1" \
370
+ ai.backend.resource.min.mem="1g" \
371
+ ai.backend.resource.min.cuda.device=1 \
372
+ ai.backend.resource.min.cuda.shares=0.1 \
373
+ ai.backend.runtime-type="python" \
374
+ ai.backend.runtime-path="/usr/bin/python3" \
375
+ ai.backend.service-ports="ipython:pty:3000,tensorboard:http:6006,jupyter:http:8080,jupyterlab:http:8090"
376
+
377
+ WORKDIR /home/work
378
+ # vim: ft=dockerfile
0 commit comments