Skip to content

Commit b0f8d5d

Browse files
committed
MXNet 1.4 support CUDA10
1 parent ec7577b commit b0f8d5d

File tree

1 file changed

+356
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)