Skip to content

Commit 4b1dffa

Browse files
authored
Merge pull request #144 from lablup/20.09
20.09
2 parents c1f0cfb + 3c26ff9 commit 4b1dffa

14 files changed

+1578
-249
lines changed

commons/Dockerfile.base

Lines changed: 370 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,370 @@
1+
FROM ubuntu:18.04
2+
3+
ENV NUMPY_VERSION 1.18.5
4+
ENV SCIPY_VERSION 1.5.2
5+
6+
# Python 2.7 or 3.6 is supported by Ubuntu Bionic out of the box
7+
ARG python=3.6
8+
ENV PYTHON_VERSION=${python}
9+
10+
ENV DEBIAN_FRONTEND=noninteractive \
11+
MPLBACKEND=Svg \
12+
PYTHONUNBUFFERED=1 \
13+
LD_LIBRARY_PATH="/usr/include/x86_64-linux-gnu:/opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64:/opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/include:/usr/local/lib:$LD_LIBRARY_PATH" \
14+
PATH="/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" \
15+
LIBRARY_PATH="/opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64" \
16+
mecab_dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic \
17+
LANG=C.UTF-8
18+
19+
# Set default shell to /bin/bash
20+
SHELL ["/bin/bash", "-cu"]
21+
22+
WORKDIR /tmp
23+
RUN apt-get update -y && \
24+
apt-get upgrade -y && \
25+
apt-get install -y --no-install-recommends \
26+
build-essential \
27+
gcc g++ make \
28+
automake \
29+
gfortran \
30+
gpg-agent \
31+
wget zip unzip \
32+
software-properties-common
33+
34+
RUN apt update -y && \
35+
add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" && \
36+
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
37+
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
38+
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
39+
wget https://apt.repos.intel.com/setup/intelproducts.list -O /etc/apt/sources.list.d/intelproducts.list && \
40+
apt-get update -y && \
41+
apt-get install -y --no-install-recommends \
42+
ca-certificates \
43+
dkms \
44+
git \
45+
curl \
46+
vim \
47+
yasm \
48+
openssh-client openssh-server \
49+
libssl-dev \
50+
libmpdec2 \
51+
pdsh curl net-tools \
52+
iputils-ping \
53+
libcurl3-dev \
54+
libfreetype6-dev \
55+
libhdf5-serial-dev \
56+
libzmq3-dev \
57+
libjpeg-dev \
58+
libpng-dev \
59+
libsm6 \
60+
libxext6 \
61+
libxrender-dev \
62+
libcairo2-dev libgirepository1.0-dev pkg-config gir1.2-gtk-3.0 \
63+
libgeos-dev libgeos++-dev \
64+
openjdk-8-jdk \
65+
pkg-config \
66+
zlib1g-dev \
67+
mime-support \
68+
proj-bin libproj-dev libgeos-dev libgeos++-dev graphviz \
69+
python${PYTHON_VERSION} \
70+
python${PYTHON_VERSION}-dev \
71+
intel-mkl-2020.3-111 intel-ipp-2020.2-108 intel-tbb-2020.3-108 intel-daal-2020.2-108 intel-mpi-2019.8-108 \
72+
libxml2-dev \
73+
libxslt1-dev \
74+
libasound2-dev \
75+
libnuma-dev \
76+
libjasper-dev \
77+
libtiff-dev \
78+
libavcodec-dev \
79+
libavformat-dev \
80+
libswscale-dev \
81+
libxine2-dev \
82+
libv4l-dev \
83+
libboost-dev \
84+
libboost-system-dev \
85+
libboost-filesystem-dev \
86+
libopenblas-dev liblapack-dev \
87+
xvfb \
88+
fonts-nanum \
89+
fonts-nanum-coding \
90+
fonts-nanum-extra \
91+
&& \
92+
rm -fr /var/lib/apt/lists/* && \
93+
echo "/opt/intel/daal/lib/intel64" >> /etc/ls.so.conf && \
94+
echo "/opt/intel/ipp/lib/intel64" >> /etc/ls.so.conf && \
95+
echo "/opt/intel/lib/intel64" >> /etc/ls.so.conf && \
96+
echo "/opt/intel/mkl/lib/intel64" >> /etc/ls.so.conf && \
97+
apt-get clean && \
98+
rm -rf /var/lib/apt/lists/* && \
99+
ldconfig
100+
101+
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
102+
apt-get update -y && \
103+
apt-get install -y --no-install-recommends nodejs && \
104+
apt-get clean && \
105+
rm -rf /var/lib/apt/lists/*
106+
107+
# OFED
108+
ENV STAGE_DIR=/tmp
109+
RUN mkdir -p ${STAGE_DIR}
110+
ENV MLNX_OFED_VERSION=4.6-1.0.1.1
111+
RUN cd ${STAGE_DIR} && \
112+
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 -
113+
RUN cd ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64 && \
114+
./mlnxofedinstall --user-space-only --without-fw-update --all -q && \
115+
cd ${STAGE_DIR} && \
116+
rm -rf ${STAGE_DIR}/MLNX_OFED_LINUX-${MLNX_OFED_VERSION}-ubuntu18.04-x86_64*
117+
118+
RUN if [[ "${PYTHON_VERSION}" == "3.6" ]]; then \
119+
apt-get install -y python${PYTHON_VERSION}-distutils python-apt ; \
120+
fi
121+
122+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2
123+
124+
WORKDIR /tmp
125+
RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \
126+
python3 -m pip install --no-cache-dir -U setuptools pip
127+
128+
RUN python3 -m pip install --no-cache-dir --upgrade -Iv \
129+
Cython==0.29.21 \
130+
tornado==6.0.4 \
131+
pystan==2.19.1.1 \
132+
pycairo==1.19.0 \
133+
python-language-server[all] \
134+
matplotlib==3.1.1
135+
136+
WORKDIR /tmp
137+
RUN git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git && \
138+
cd OpenBLAS && \
139+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran NO_CBLAS=1 NO_LAPACK=1 NO_LAPACKE=1 && \
140+
make install
141+
142+
RUN git clone --recursive https://github.com/bodono/scs-python.git && \
143+
cd /tmp/scs-python && \
144+
python setup.py install --scs
145+
146+
RUN cd /tmp && \
147+
git clone --branch=v${NUMPY_VERSION} --depth=1 https://github.com/numpy/numpy.git numpy && \
148+
cd numpy && \
149+
git checkout -b v${NUMPY_VERSION} && \
150+
cp site.cfg.example site.cfg && \
151+
echo "[mkl]" >> site.cfg && \
152+
echo "include_dirs = /opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/include/" >> site.cfg && \
153+
echo "library_dirs = /opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64" >> site.cfg && \
154+
echo "mkl_libs = mkl_rt" >> site.cfg && \
155+
echo "lapack_libs =" >> site.cfg && \
156+
python3 setup.py bdist_wheel -d /tmp
157+
158+
# Install scipy
159+
RUN cd /tmp && \
160+
git clone --branch=v${SCIPY_VERSION} --depth=1 https://github.com/scipy/scipy.git scipy && \
161+
cd scipy && \
162+
git checkout -b v${SCIPY_VERSION} && \
163+
cp site.cfg.example site.cfg && \
164+
echo "[mkl]" >> site.cfg && \
165+
echo "include_dirs = /opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/include/" >> site.cfg && \
166+
echo "library_dirs = /opt/intel/compilers_and_libraries_2020.3.279/linux/mkl/lib/intel64" >> site.cfg && \
167+
echo "mkl_libs = mkl_rt" >> site.cfg && \
168+
echo "lapack_libs =" >> site.cfg && \
169+
python3 -m pip install -U --no-cache-dir /tmp/numpy-${NUMPY_VERSION}-cp36-cp36m-linux_x86_64.whl && \
170+
python3 setup.py install
171+
172+
RUN python3 -m pip install pip --no-cache-dir \
173+
Cartopy==0.18.0 \
174+
notebook==6.0.3
175+
176+
WORKDIR /tmp
177+
COPY ./requirements.txt /tmp
178+
RUN python3 -m pip install --no-cache-dir --upgrade -r requirements.txt && \
179+
python3 -m pip install --no-cache-dir tensorflow_model_analysis && \
180+
python3 -m pip uninstall -y \
181+
tensorboard tensorboard-plugin-wit tensorflow \
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+
torch && \
187+
rm -f /tmp/requirements.txt
188+
189+
# install NLP packages *mecab-ko & khai*
190+
WORKDIR /tmp
191+
RUN curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
192+
tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
193+
cd mecab-0.996-ko-0.9.2 && \
194+
./configure && \
195+
make -j$(nproc) && \
196+
make check && \
197+
make install
198+
199+
# Install mecab-ko-dic"
200+
WORKDIR /tmp
201+
RUN curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
202+
tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
203+
cd mecab-ko-dic-2.1.1-20180720 && \
204+
./autogen.sh && \
205+
./configure && \
206+
make -j$(nproc) && \
207+
sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \
208+
make install && \
209+
cd /tmp && \
210+
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
211+
python3 -m pip install /tmp/mecab-python-0.996
212+
213+
# OpenCV
214+
RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
215+
apt-get install -y \
216+
libgstreamer1.0-dev \
217+
libgstreamer-plugins-base1.0-dev \
218+
libgtk-3-dev \
219+
libtbb-dev \
220+
libatlas-base-dev \
221+
libdc1394-22-dev \
222+
libxvidcore-dev \
223+
libfaac-dev \
224+
libmp3lame-dev \
225+
libtheora-dev \
226+
libvorbis-dev \
227+
libxvidcore-dev \
228+
libopencore-amrnb-dev libopencore-amrwb-dev \
229+
libavresample-dev \
230+
x264 \
231+
libx264-dev \
232+
v4l-utils \
233+
libprotobuf-dev protobuf-compiler \
234+
libgoogle-glog-dev libgflags-dev \
235+
libgphoto2-dev \
236+
libeigen3-dev \
237+
libhdf5-dev \
238+
&& \
239+
apt-get clean && \
240+
rm -rf /var/lib/apt/lists/*
241+
242+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1-Linux-x86_64.sh \
243+
-q -O /tmp/cmake-install.sh && \
244+
chmod u+x /tmp/cmake-install.sh && \
245+
mkdir /usr/bin/cmake && \
246+
/tmp/cmake-install.sh --skip-license --prefix=/usr/bin/cmake && \
247+
rm /tmp/cmake-install.sh
248+
249+
WORKDIR /tmp
250+
ENV OPENCV_VERSION="4.4.0"
251+
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
252+
wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
253+
unzip ${OPENCV_VERSION}.zip && \
254+
unzip opencv-contrib.zip && \
255+
mkdir opencv-${OPENCV_VERSION}/cmake_binary && \
256+
cd opencv-${OPENCV_VERSION}/cmake_binary && \
257+
cmake \
258+
-DCMAKE_BUILD_TYPE=RELEASE \
259+
-D BUILD_TIFF=ON \
260+
-D BUILD_opencv_java=OFF \
261+
-D ENABLE_FAST_MATH=1 \
262+
-D WITH_IPP=ON \
263+
-D WITH_TBB=ON \
264+
-D WITH_EIGEN=ON \
265+
-D WITH_V4L=ON \
266+
-D BUILD_TESTS=OFF \
267+
-D BUILD_PERF_TESTS=OFF \
268+
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.4.0/modules" \
269+
-D CMAKE_BUILD_TYPE=RELEASE \
270+
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
271+
-D PYTHON_EXECUTABLE=$(which python3) \
272+
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
273+
-D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
274+
.. 2>&1 | tee cmake_messages.txt && \
275+
make -j$(nproc) && \
276+
make install && \
277+
cd /tmp && \
278+
python3 -m pip install --no-cache-dir opencv-python && \
279+
rm -fr opencv*
280+
281+
# XGBoost
282+
RUN git clone --recursive https://github.com/dmlc/xgboost && \
283+
cd xgboost && \
284+
mkdir build && \
285+
cd build && \
286+
cmake .. && \
287+
make -j$(nproc) && \
288+
cd ../python-package && \
289+
python3 setup.py install
290+
291+
# LightGBM
292+
RUN cd /usr/local/src && mkdir lightgbm && cd lightgbm && \
293+
git clone --recursive --branch stable --depth 1 https://github.com/microsoft/LightGBM && \
294+
cd LightGBM && mkdir build && cd build && \
295+
cmake .. && \
296+
make -j$(nproc) && \
297+
cd /usr/local/src/lightgbm/LightGBM/python-package && \
298+
python3 setup.py install --precompile
299+
300+
# Install Open MPI
301+
RUN mkdir /tmp/openmpi && \
302+
cd /tmp/openmpi && \
303+
wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.4.tar.gz && \
304+
tar zxf openmpi-4.0.4.tar.gz && \
305+
cd openmpi-4.0.4 && \
306+
./configure --enable-orterun-prefix-by-default && \
307+
make -j $(nproc) all && \
308+
make install && \
309+
ldconfig && \
310+
rm -rf /tmp/openmpi*
311+
312+
# Install OpenSSH for MPI to communicate between containers
313+
RUN apt-get install -y --no-install-recommends openssh-client openssh-server && \
314+
mkdir -p /var/run/sshd
315+
316+
# Allow OpenSSH to talk to containers without asking for confirmation
317+
RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \
318+
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \
319+
mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config
320+
321+
# Create a wrapper for OpenMPI to allow running as root by default
322+
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
323+
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
324+
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
325+
chmod a+x /usr/local/bin/mpirun
326+
327+
# Configure OpenMPI to run good defaults:
328+
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
329+
330+
# Install OpenSSH for MPI to communicate between containers
331+
RUN 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 git-lfs
339+
WORKDIR /tmp
340+
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.11.0/git-lfs-linux-amd64-v2.11.0.tar.gz && \
341+
tar -zxf git-lfs-linux-amd64-v2.11.0.tar.gz && \
342+
bash install.sh
343+
344+
COPY ./service-defs /etc/backend.ai/service-defs
345+
RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.4.1/code-server-3.4.1-linux-amd64.tar.gz \
346+
| tar -C /usr/local/lib -xz && \
347+
mv /usr/local/lib/code-server-3.4.1-linux-amd64 /usr/local/lib/code-server-3.4.1 && \
348+
ln -s /usr/local/lib/code-server-3.4.1/bin/code-server /usr/local/bin/code-server
349+
350+
RUN jupyter nbextensions_configurator enable && \
351+
jupyter contrib nbextension install && \
352+
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
353+
jupyter serverextension enable --py jupyterlab --sys-prefix && \
354+
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager && \
355+
jupyter labextension install --no-build @krassowski/jupyterlab-lsp && \
356+
jupyter serverextension enable --py jupyter_lsp && \
357+
jupyter labextension install --no-build @jupyterlab/toc && \
358+
jupyter nbextension enable execute_time/ExecuteTime && \
359+
jupyter nbextension enable toc2/main && \
360+
jupyter labextension install @pyviz/jupyterlab_pyviz && \
361+
jupyter labextension install @bokeh/jupyter_bokeh && \
362+
jupyter labextension install --no-build jupyterlab-nvdashboard && \
363+
jupyter lab build
364+
365+
RUN apt autoclean && \
366+
rm -rf /var/lib/apt/lists/* && \
367+
rm -rf /root/.cache && \
368+
rm -rf /tmp
369+
370+
WORKDIR /home/work

0 commit comments

Comments
 (0)