Skip to content

Commit 57d1556

Browse files
committed
Base container based on py36 and CUDA10.2"
1 parent c2d160b commit 57d1556

File tree

1 file changed

+397
-0
lines changed

1 file changed

+397
-0
lines changed
Lines changed: 397 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,397 @@
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_16.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+
115+
# Add OpenCL ICD files for LightGBM
116+
RUN mkdir -p /etc/OpenCL/vendors && \
117+
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
118+
119+
# OFED
120+
#ENV STAGE_DIR=/tmp
121+
#RUN mkdir -p ${STAGE_DIR}
122+
#ENV MLNX_OFED_VERSION=4.6-1.0.1.1
123+
#RUN cd ${STAGE_DIR} && \
124+
# 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 -
125+
#RUN cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
126+
# ./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
127+
# cd ${STAGE_DIR} && \
128+
# rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
129+
130+
# nvidia-peer
131+
#RUN mkdir -p ${STAGE_DIR} && \
132+
# git clone https://github.com/Mellanox/nv_peer_memory.git ${STAGE_DIR}/nv_peer_memory && \
133+
# cd ${STAGE_DIR}/nv_peer_memory && \
134+
# ./build_module.sh && \
135+
# cd ${STAGE_DIR} && \
136+
# tar xzf ${STAGE_DIR}/nvidia-peer-memory_1.1.orig.tar.gz && \
137+
# cd ${STAGE_DIR}/nvidia-peer-memory-1.1 && \
138+
# dpkg-buildpackage -us -uc && \
139+
# dpkg -i ${STAGE_DIR}/nvidia-peer-memory_1.1-0_all.deb
140+
141+
RUN if [[ "${PYTHON_VERSION}" == "3.6" ]]; then \
142+
apt-get install -y python${PYTHON_VERSION}-distutils python-apt ; \
143+
fi
144+
145+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2
146+
147+
RUN apt-get update -y && \
148+
apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
149+
libatlas-base-dev libopenblas-dev
150+
151+
WORKDIR /tmp
152+
RUN curl https://bootstrap.pypa.io/pip/3.6/get-pip.py | python3 && \
153+
python3 -m pip install --no-cache-dir -U setuptools==59.6.0 pip==21.1.3
154+
155+
RUN python3 -m pip install --no-cache-dir --upgrade -Iv \
156+
Cython==0.29.20 \
157+
tornado==6.0.4 \
158+
pystan==2.19.1.1 \
159+
pycairo==1.19.0 \
160+
python-language-server[all] \
161+
matplotlib==3.1.1
162+
163+
WORKDIR /tmp
164+
RUN git clone -q --branch=master https://github.com/xianyi/OpenBLAS.git && \
165+
cd OpenBLAS && \
166+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
167+
make install
168+
RUN \
169+
# git clone --recursive --brnch https://github.com/bodono/scs-python.git && \
170+
# cd /tmp/scs-python && \
171+
python -m pip install scs
172+
173+
RUN python3 -m pip install pip --no-cache-dir \
174+
Cartopy==0.18.0 \
175+
notebook==6.0.3
176+
177+
WORKDIR /tmp
178+
COPY ./requirements.22.11.txt /tmp
179+
RUN python3 -m pip install --no-cache-dir --upgrade -r requirements.22.11.txt && \
180+
python3 -m pip install --no-cache-dir tensorflow_model_analysis && \
181+
python3 -m pip uninstall -y tensorboard tensorboard-plugin-wit tensorflow tensorflow-gpu \
182+
tensorflow-estimator tensorflow-addons tensorflow-datasets \
183+
tensorflow-gan tensorflow-hub tensorflow-metadata \
184+
tensorflow-probability tensorflow-text \
185+
tensorflow-model-analysis tensorflow-serving-api && \
186+
rm -f /tmp/*.whl /tmp/requirements.22.11.txt
187+
188+
# install NLP packages *mecab-ko & khai*
189+
RUN apt-get update && \
190+
apt-get install -y \
191+
openjdk-8-jdk \
192+
automake \
193+
&& \
194+
cd /tmp && \
195+
curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
196+
tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
197+
cd mecab-0.996-ko-0.9.2 && \
198+
./configure && \
199+
make -j$(nproc) && \
200+
make check && \
201+
make install
202+
203+
RUN echo "Install mecab-ko-dic" && \
204+
cd /tmp && \
205+
ldconfig && \
206+
curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
207+
tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
208+
cd mecab-ko-dic-2.1.1-20180720 && \
209+
./autogen.sh && \
210+
./configure && \
211+
make -j$(nproc) && \
212+
sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \
213+
make install && \
214+
cd /tmp && \
215+
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
216+
python3 -m pip install /tmp/mecab-python-0.996
217+
218+
# OpenCV
219+
RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
220+
apt-get install -y \
221+
libgstreamer1.0-dev \
222+
libgstreamer-plugins-base1.0-dev \
223+
libgtk-3-dev \
224+
libtbb-dev \
225+
libatlas-base-dev \
226+
libdc1394-22-dev \
227+
libxvidcore-dev \
228+
libfaac-dev \
229+
libmp3lame-dev \
230+
libtheora-dev \
231+
libvorbis-dev \
232+
libxvidcore-dev \
233+
libopencore-amrnb-dev libopencore-amrwb-dev \
234+
libavresample-dev \
235+
x264 \
236+
libx264-dev \
237+
v4l-utils \
238+
libprotobuf-dev protobuf-compiler \
239+
libgoogle-glog-dev libgflags-dev \
240+
libgphoto2-dev \
241+
libeigen3-dev \
242+
libhdf5-dev \
243+
&& \
244+
apt-get clean && \
245+
rm -rf /var/lib/apt/lists/
246+
247+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1-Linux-x86_64.sh \
248+
-q -O /tmp/cmake-install.sh && \
249+
chmod u+x /tmp/cmake-install.sh && \
250+
mkdir /usr/bin/cmake && \
251+
/tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake && \
252+
rm /tmp/cmake-install.sh
253+
254+
WORKDIR /tmp
255+
ENV OPENCV_VERSION="4.4.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.2 \
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.4.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+
python3 -m pip install --no-cache-dir opencv-python && \
291+
rm -fr opencv*
292+
293+
# XGBoost
294+
RUN git clone --recursive -b v1.2.1 https://github.com/dmlc/xgboost && \
295+
cd xgboost && \
296+
mkdir build && \
297+
cd build && \
298+
cmake .. -DUSE_CUDA=ON -DUSE_NCCL=ON && \
299+
make -j$(nproc) && \
300+
cd ../python-package && \
301+
python3 setup.py install
302+
303+
# LightGBM
304+
RUN cd /usr/local/src && mkdir lightgbm && cd lightgbm && \
305+
git clone --recursive --branch stable --depth 1 https://github.com/microsoft/LightGBM && \
306+
cd LightGBM && mkdir build && cd build && \
307+
cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ .. && \
308+
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) && \
309+
cd /usr/local/src/lightgbm/LightGBM/python-package && \
310+
python3 setup.py install --precompile
311+
312+
# Install Open MPI
313+
RUN mkdir /tmp/openmpi && \
314+
cd /tmp/openmpi && \
315+
wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.4.tar.gz && \
316+
tar zxf openmpi-4.0.4.tar.gz && \
317+
cd openmpi-4.0.4 && \
318+
./configure --enable-orterun-prefix-by-default && \
319+
make -j $(nproc) all && \
320+
make install && \
321+
ldconfig && \
322+
rm -rf /tmp/openmpi*
323+
324+
# Install OpenSSH for MPI to communicate between containers
325+
RUN apt-get install -y --no-install-recommends openssh-client openssh-server && \
326+
mkdir -p /var/run/sshd
327+
328+
# Allow OpenSSH to talk to containers without asking for confirmation
329+
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
330+
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
331+
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
332+
333+
# Create a wrapper for OpenMPI to allow running as root by default
334+
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
335+
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
336+
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
337+
chmod a+x /usr/local/bin/mpirun
338+
339+
# Configure OpenMPI to run good defaults:
340+
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
341+
342+
# Install OpenSSH for MPI to communicate between containers
343+
RUN mkdir -p /var/run/sshd
344+
345+
# Allow OpenSSH to talk to containers without asking for confirmation
346+
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
347+
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
348+
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
349+
350+
# install git-lfs
351+
WORKDIR /tmp
352+
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.11.0/git-lfs-linux-amd64-v2.11.0.tar.gz && \
353+
tar -zxf git-lfs-linux-amd64-v2.11.0.tar.gz && \
354+
bash install.sh && \
355+
rm -rf /tmp/*
356+
357+
COPY ./service-defs /etc/backend.ai/service-defs
358+
RUN curl -fL https://github.com/cdr/code-server/releases/download/v4.8.3/code-server-4.8.3-linux-amd64.tar.gz \
359+
| tar -C /usr/local/lib -xz && \
360+
mv /usr/local/lib/code-server-4.8.3-linux-amd64 /usr/local/lib/code-server-4.8.3 && \
361+
ln -s /usr/local/lib/code-server-4.8.3/bin/code-server /usr/local/bin/code-server
362+
363+
RUN jupyter nbextensions_configurator enable && \
364+
jupyter contrib nbextension install && \
365+
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
366+
jupyter contrib nbextension install && \
367+
jupyter serverextension enable --py jupyterlab --sys-prefix && \
368+
jupyter labextension install @jupyter-widgets/jupyterlab-manager && \
369+
# jupyter labextension install jupyterlab-nvdashboard && \
370+
git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding && \
371+
jupyter nbextension enable /home/work/.jupyter/nbextension/vim_binding/vim_binding
372+
373+
#RUN jupyter nbextensions_configurator enable && \
374+
# jupyter contrib nbextension install && \
375+
# jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
376+
# jupyter serverextension enable --py jupyterlab --sys-prefix && \
377+
# jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager && \
378+
# git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding && \
379+
# jupyter nbextension enable /home/work/.jupyter/nbextension/vim_binding/vim_binding && \
380+
# jupyter labextension install --no-build @lckr/jupyterlab_variableinspector && \
381+
# jupyter labextension install --no-build @krassowski/jupyterlab-lsp && \
382+
# jupyter serverextension enable --py jupyter_lsp && \
383+
# jupyter labextension install --no-build @jupyterlab/toc && \
384+
# jupyter labextension install @jupyterlab/hdf5
385+
# jupyter nbextension enable execute_time/ExecuteTime && \
386+
# jupyter nbextension enable toc2/main && \
387+
# jupyter labextension install @pyviz/jupyterlab_pyviz && \
388+
# jupyter labextension install @bokeh/jupyter_bokeh && \
389+
# jupyter labextension install --no-build jupyterlab-nvdashboard && \
390+
# jupyter lab build
391+
392+
RUN apt autoclean && \
393+
rm -rf /var/lib/apt/lists/* && \
394+
rm -rf /root/.cache && \
395+
rm -rf /tmp/*
396+
397+
WORKDIR /home/work

0 commit comments

Comments
 (0)