Skip to content

Commit 06c312f

Browse files
committed
Base kernel 20.08 for python 3.6 & CUDA10.2
1 parent 652098f commit 06c312f

File tree

1 file changed

+399
-0
lines changed

1 file changed

+399
-0
lines changed
Lines changed: 399 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,399 @@
1+
FROM nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04
2+
3+
# TensorFlow version is tightly coupled to CUDA and cuDNN so it should be selected carefully
4+
ARG CUDA=10.2
5+
ARG LIBNVINFER=7.1.3-1
6+
ARG LIBNVINFER_MAJOR_VERSION=7
7+
ARG CUDNN=7.6.5.32-1
8+
ENV NCCL_VERSION=2.7.8-1+cuda10.2
9+
ENV CUDNN_VERSION 8.0.2.39
10+
11+
# Python 2.7 or 3.6 is supported by Ubuntu Bionic out of the box
12+
ARG python=3.6
13+
ENV PYTHON_VERSION=${python}
14+
15+
ENV DEBIAN_FRONTEND=noninteractive \
16+
MPLBACKEND=Svg \
17+
PYTHONUNBUFFERED=1 \
18+
LD_LIBRARY_PATH="/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/nvidia/lib64:/usr/include/x86_64-linux-gnu" \
19+
PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/bin/cmake/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/src/lightgbm/LightGBM:/usr/local/bin/mecab" \
20+
mecab_dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic \
21+
LANG=C.UTF-8
22+
23+
# Set default shell to /bin/bash
24+
SHELL ["/bin/bash", "-cu"]
25+
26+
RUN apt-get update -y && \
27+
apt-get install -y --no-install-recommends software-properties-common && \
28+
add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" && \
29+
apt-get update -y && \
30+
apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
31+
build-essential \
32+
ca-certificates \
33+
gcc g++ make \
34+
gfortran \
35+
dkms \
36+
git \
37+
curl \
38+
vim \
39+
yasm \
40+
wget zip unzip \
41+
software-properties-common \
42+
openssh-client openssh-server \
43+
libssl-dev \
44+
libmpdec2 \
45+
pdsh curl net-tools \
46+
iputils-ping \
47+
libcurl3-dev \
48+
libfreetype6-dev \
49+
libhdf5-serial-dev \
50+
libzmq3-dev \
51+
libjpeg-dev \
52+
libpng-dev \
53+
libsm6 \
54+
libxext6 \
55+
libxrender-dev \
56+
libcairo2-dev libgirepository1.0-dev pkg-config gir1.2-gtk-3.0 \
57+
libgeos-dev libgeos++-dev \
58+
pkg-config \
59+
zlib1g-dev \
60+
mime-support \
61+
proj-bin libproj-dev libgeos-dev libgeos++-dev graphviz \
62+
python${PYTHON_VERSION} \
63+
python${PYTHON_VERSION}-dev \
64+
libxml2-dev \
65+
libxslt1-dev \
66+
libasound2-dev \
67+
libnuma-dev \
68+
libjasper-dev \
69+
libtiff-dev \
70+
libavcodec-dev \
71+
libavformat-dev \
72+
libswscale-dev \
73+
libxine2-dev \
74+
libv4l-dev \
75+
libboost-dev \
76+
libboost-system-dev \
77+
libboost-filesystem-dev \
78+
xvfb \
79+
fonts-nanum \
80+
fonts-nanum-coding \
81+
fonts-nanum-extra \
82+
&& \
83+
find /usr/local/cuda-${CUDA}/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete
84+
85+
86+
RUN apt update && apt install curl xz-utils -y --no-install-recommends && NCCL_DOWNLOAD_SUM=34000cbe6a0118bfd4ad898ebc5f59bf5d532bbf2453793891fa3f1621e25653 && \
87+
curl -fsSL https://developer.download.nvidia.com/compute/redist/nccl/v2.7/nccl_2.7.8-1+cuda10.2_x86_64.txz -O && \
88+
# echo "$NCCL_DOWNLOAD_SUM nccl_2.7.8-1+cuda10.2_x86_64.txz" | sha256sum -c - && \
89+
tar --no-same-owner --keep-old-files --lzma -xvf nccl_2.7.8-1+cuda10.2_x86_64.txz -C /usr/local/cuda/lib64/ --strip-components=2 --wildcards '*/lib/libnccl.so.*' && \
90+
tar --no-same-owner --keep-old-files --lzma -xvf nccl_2.7.8-1+cuda10.2_x86_64.txz -C /usr/lib/pkgconfig/ --strip-components=3 --wildcards '*/lib/pkgconfig/*' && \
91+
rm nccl_2.7.8-1+cuda10.2_x86_64.txz && \
92+
ldconfig && rm -rf /var/lib/apt/lists/*
93+
94+
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
95+
echo "/usr/local/cuda/lib64/stubs" > /etc/ld.so.conf.d/z-cuda-stubs.conf && \
96+
ldconfig
97+
98+
# Install CUDA-10.2 + cuDNN 8.0.2
99+
RUN ln -s /usr/local/cuda-10.2 /usr/local/cuda && \
100+
ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.7.8.0 /usr/local/cuda/lib64/libcudnn.so && \
101+
ldconfig
102+
103+
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
104+
apt-get update -y && \
105+
apt-get install -y nodejs
106+
107+
RUN apt-get update && \
108+
apt-get install -y --no-install-recommends libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
109+
libnvinfer-dev=${LIBNVINFER}+cuda${CUDA} \
110+
libnvinfer-plugin-dev=${LIBNVINFER}+cuda${CUDA} \
111+
libnvinfer-plugin${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
112+
&& apt-get clean \
113+
&& rm -rf /var/lib/apt/lists/*
114+
#RUN apt-get update && \
115+
# apt-get install -y --no-install-recommends \#
116+
# libnvinfer${LIBNVINFER_MAJOR_VERSION}=${LIBNVINFER}+cuda${CUDA} \
117+
# libnvinfer-dev=${LIBNVINFER}+cuda${CUDA} \
118+
# libnvinfer-plugin-dev=${LIBNVINFER}+cuda${CUDA} \
119+
# && \
120+
# apt-get clean && \
121+
# rm -rf /var/lib/apt/lists/*
122+
123+
# Add OpenCL ICD files for LightGBM
124+
RUN mkdir -p /etc/OpenCL/vendors && \
125+
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
126+
127+
# OFED
128+
ENV STAGE_DIR=/tmp
129+
RUN mkdir -p ${STAGE_DIR}
130+
ENV MLNX_OFED_VERSION=4.6-1.0.1.1
131+
RUN cd ${STAGE_DIR} && \
132+
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 -
133+
RUN cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
134+
./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
135+
cd ${STAGE_DIR} && \
136+
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
137+
138+
# nvidia-peer
139+
RUN mkdir -p ${STAGE_DIR} && \
140+
git clone https://github.com/Mellanox/nv_peer_memory.git ${STAGE_DIR}/nv_peer_memory && \
141+
cd ${STAGE_DIR}/nv_peer_memory && \
142+
./build_module.sh && \
143+
cd ${STAGE_DIR} && \
144+
tar xzf ${STAGE_DIR}/nvidia-peer-memory_1.1.orig.tar.gz && \
145+
cd ${STAGE_DIR}/nvidia-peer-memory-1.1 && \
146+
dpkg-buildpackage -us -uc && \
147+
dpkg -i ${STAGE_DIR}/nvidia-peer-memory_1.1-0_all.deb
148+
149+
RUN if [[ "${PYTHON_VERSION}" == "3.6" ]]; then \
150+
apt-get install -y python${PYTHON_VERSION}-distutils python-apt ; \
151+
fi
152+
153+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2
154+
155+
RUN apt-get update -y && \
156+
apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
157+
libatlas-base-dev libopenblas-dev
158+
159+
WORKDIR /tmp
160+
RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \
161+
python3 -m pip install --no-cache-dir -U setuptools pip
162+
163+
COPY ./numpy-1.18.5-cp36-cp36m-manylinux2010_x86_64.whl /tmp
164+
COPY ./pandas-1.0.4+4.g29edbab4a-cp36-cp36m-linux_x86_64.whl /tmp
165+
166+
RUN python3 -m pip install --no-cache-dir --upgrade -Iv \
167+
Cython==0.29.20 \
168+
/tmp/numpy-1.18.5-cp36-cp36m-manylinux2010_x86_64.whl \
169+
/tmp/pandas-1.0.4+4.g29edbab4a-cp36-cp36m-linux_x86_64.whl \
170+
tornado==6.0.4 \
171+
pystan==2.19.1.1 \
172+
pycairo==1.19.0 \
173+
python-language-server[all] \
174+
matplotlib==3.1.1
175+
176+
WORKDIR /tmp
177+
RUN git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git && \
178+
cd OpenBLAS && \
179+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
180+
make install
181+
RUN git clone --recursive https://github.com/bodono/scs-python.git && \
182+
cd /tmp/scs-python && \
183+
python setup.py install --scs --gpu
184+
185+
RUN python3 -m pip install pip --no-cache-dir \
186+
Cartopy==0.18.0 \
187+
notebook==6.0.3
188+
189+
WORKDIR /tmp
190+
COPY ./requirements.20.08.txt /tmp
191+
RUN python3 -m pip install --no-cache-dir --upgrade -r requirements.20.08.txt && \
192+
python3 -m pip install --no-cache-dir tensorflow_model_analysis && \
193+
python3 -m pip uninstall -y tensorboard tensorboard-plugin-wit tensorflow tensorflow-gpu \
194+
tensorflow-estimator tensorflow-addons tensorflow-datasets \
195+
tensorflow-gan tensorflow-hub tensorflow-metadata \
196+
tensorflow-probability tensorflow-text \
197+
tensorflow-model-analysis tensorflow-serving-api && \
198+
rm -f /tmp/*.whl /tmp/requirements.20.08.txt
199+
200+
# install NLP packages *mecab-ko & khai*
201+
RUN apt-get update && \
202+
apt-get install -y \
203+
openjdk-8-jdk \
204+
automake \
205+
&& \
206+
cd /tmp && \
207+
curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
208+
tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
209+
cd mecab-0.996-ko-0.9.2 && \
210+
./configure && \
211+
make -j$(nproc) && \
212+
make check && \
213+
make install
214+
215+
RUN echo "Install mecab-ko-dic" && \
216+
cd /tmp && \
217+
ldconfig && \
218+
curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
219+
tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
220+
cd mecab-ko-dic-2.1.1-20180720 && \
221+
./autogen.sh && \
222+
./configure && \
223+
make -j$(nproc) && \
224+
sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \
225+
make install && \
226+
cd /tmp && \
227+
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
228+
python3 -m pip install /tmp/mecab-python-0.996
229+
230+
# OpenCV
231+
RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
232+
apt-get install -y \
233+
libgstreamer1.0-dev \
234+
libgstreamer-plugins-base1.0-dev \
235+
libgtk-3-dev \
236+
libtbb-dev \
237+
libatlas-base-dev \
238+
libdc1394-22-dev \
239+
libxvidcore-dev \
240+
libfaac-dev \
241+
libmp3lame-dev \
242+
libtheora-dev \
243+
libvorbis-dev \
244+
libxvidcore-dev \
245+
libopencore-amrnb-dev libopencore-amrwb-dev \
246+
libavresample-dev \
247+
x264 \
248+
libx264-dev \
249+
v4l-utils \
250+
libprotobuf-dev protobuf-compiler \
251+
libgoogle-glog-dev libgflags-dev \
252+
libgphoto2-dev \
253+
libeigen3-dev \
254+
libhdf5-dev \
255+
&& \
256+
apt-get clean && \
257+
rm -rf /var/lib/apt/lists/
258+
259+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1-Linux-x86_64.sh \
260+
-q -O /tmp/cmake-install.sh && \
261+
chmod u+x /tmp/cmake-install.sh && \
262+
mkdir /usr/bin/cmake && \
263+
/tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake && \
264+
rm /tmp/cmake-install.sh
265+
266+
WORKDIR /tmp
267+
ENV OPENCV_VERSION="4.4.0"
268+
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
269+
wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
270+
unzip ${OPENCV_VERSION}.zip && \
271+
unzip opencv-contrib.zip && \
272+
mkdir opencv-${OPENCV_VERSION}/cmake_binary && \
273+
cd opencv-${OPENCV_VERSION}/cmake_binary && \
274+
cmake \
275+
-DCMAKE_BUILD_TYPE=RELEASE \
276+
-D BUILD_TIFF=ON \
277+
-D BUILD_opencv_java=OFF \
278+
-D WITH_CUDA=ON \
279+
-D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
280+
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2 \
281+
-D ENABLE_FAST_MATH=1 \
282+
-D CUDA_FAST_MATH=1 \
283+
-D WITH_CUBLAS=1 \
284+
-D WITH_OPENGL=ON \
285+
-D WITH_OPENCL=ON \
286+
-D WITH_IPP=ON \
287+
-D WITH_TBB=ON \
288+
-D WITH_EIGEN=ON \
289+
-D WITH_V4L=ON \
290+
-D BUILD_TESTS=OFF \
291+
-D BUILD_PERF_TESTS=OFF \
292+
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.4.0/modules" \
293+
-D CMAKE_BUILD_TYPE=RELEASE \
294+
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
295+
-D PYTHON_EXECUTABLE=$(which python3) \
296+
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
297+
-D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
298+
.. 2>&1 | tee cmake_messages.txt && \
299+
make -j$(nproc) && \
300+
make install && \
301+
cd /tmp && \
302+
python3 -m pip install --no-cache-dir opencv-python && \
303+
rm -fr opencv*
304+
305+
# XGBoost
306+
RUN git clone --recursive https://github.com/dmlc/xgboost && \
307+
cd xgboost && \
308+
mkdir build && \
309+
cd build && \
310+
cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON && \
311+
make -j$(nproc) && \
312+
cd ../python-package && \
313+
python3 setup.py install
314+
315+
# LightGBM
316+
RUN cd /usr/local/src && mkdir lightgbm && cd lightgbm && \
317+
git clone --recursive --branch stable --depth 1 https://github.com/microsoft/LightGBM && \
318+
cd LightGBM && mkdir build && cd build && \
319+
cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ .. && \
320+
make OPENCL_HEADERS=/usr/local/cuda-10.2/targets/x86_64-linux/include LIBOPENCL=/usr/local/cuda-10.2/targets/x86_64-linux/lib -j$(nproc) && \
321+
cd /usr/local/src/lightgbm/LightGBM/python-package && \
322+
python3 setup.py install --precompile
323+
324+
# Install Open MPI
325+
RUN mkdir /tmp/openmpi && \
326+
cd /tmp/openmpi && \
327+
wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.4.tar.gz && \
328+
tar zxf openmpi-4.0.4.tar.gz && \
329+
cd openmpi-4.0.4 && \
330+
./configure --enable-orterun-prefix-by-default && \
331+
make -j $(nproc) all && \
332+
make install && \
333+
ldconfig && \
334+
rm -rf /tmp/openmpi*
335+
336+
# Install OpenSSH for MPI to communicate between containers
337+
RUN apt-get install -y --no-install-recommends openssh-client openssh-server && \
338+
mkdir -p /var/run/sshd
339+
340+
# Allow OpenSSH to talk to containers without asking for confirmation
341+
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
342+
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
343+
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
344+
345+
# Create a wrapper for OpenMPI to allow running as root by default
346+
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
347+
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
348+
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
349+
chmod a+x /usr/local/bin/mpirun
350+
351+
# Configure OpenMPI to run good defaults:
352+
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
353+
354+
# Install OpenSSH for MPI to communicate between containers
355+
RUN mkdir -p /var/run/sshd
356+
357+
# Allow OpenSSH to talk to containers without asking for confirmation
358+
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
359+
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
360+
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
361+
362+
# install git-lfs
363+
WORKDIR /tmp
364+
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.11.0/git-lfs-linux-amd64-v2.11.0.tar.gz && \
365+
tar -zxf git-lfs-linux-amd64-v2.11.0.tar.gz && \
366+
bash install.sh && \
367+
rm -rf /tmp/*
368+
369+
COPY ./service-defs /etc/backend.ai/service-defs
370+
RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.4.1/code-server-3.4.1-linux-amd64.tar.gz \
371+
| tar -C /usr/local/lib -xz && \
372+
mv /usr/local/lib/code-server-3.4.1-linux-amd64 /usr/local/lib/code-server-3.4.1 && \
373+
ln -s /usr/local/lib/code-server-3.4.1/bin/code-server /usr/local/bin/code-server
374+
375+
RUN jupyter nbextensions_configurator enable && \
376+
jupyter contrib nbextension install && \
377+
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
378+
jupyter serverextension enable --py jupyterlab --sys-prefix && \
379+
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager && \
380+
# git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding && \
381+
# jupyter nbextension enable /home/work/.jupyter/nbextension/vim_binding/vim_binding && \
382+
# jupyter labextension install --no-build @lckr/jupyterlab_variableinspector && \
383+
jupyter labextension install --no-build @krassowski/jupyterlab-lsp && \
384+
jupyter serverextension enable --py jupyter_lsp && \
385+
jupyter labextension install --no-build @jupyterlab/toc && \
386+
# jupyter labextension install @jupyterlab/hdf5
387+
jupyter nbextension enable execute_time/ExecuteTime && \
388+
jupyter nbextension enable toc2/main && \
389+
jupyter labextension install @pyviz/jupyterlab_pyviz && \
390+
jupyter labextension install @bokeh/jupyter_bokeh && \
391+
jupyter labextension install --no-build jupyterlab-nvdashboard && \
392+
jupyter lab build
393+
394+
RUN apt autoclean && \
395+
rm -rf /var/lib/apt/lists/* && \
396+
rm -rf /root/.cache && \
397+
rm -rf /tmp/*
398+
399+
WORKDIR /home/work

0 commit comments

Comments
 (0)