Skip to content

Commit 312f44b

Browse files
committed
2 parents 538809f + 5abcd1f commit 312f44b

File tree

1 file changed

+237
-0
lines changed

1 file changed

+237
-0
lines changed
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
FROM nvcr.io/nvidia/tensorflow:21.03-tf1-py3
2+
# NVIDIA DIGITS runs on Python 3.8
3+
4+
RUN apt-get update && \
5+
apt-get install -y libsm6 libxext6 libxrender-dev mercurial libgdal-dev python3-gdal \
6+
libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev \
7+
libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
8+
9+
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
10+
ENV C_INCLUDE_PATH=/usr/include/gdal
11+
ENV DEBIAN_FRONTEND=noninteractive \
12+
MPLBACKEND=Svg \
13+
PYTHONUNBUFFERED=1 \
14+
LD_LIBRARY_PATH="/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/nvidia/lib64:/usr/include/x86_64-linux-gnu" \
15+
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" \
16+
mecab_dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic \
17+
LANG=C.UTF-8
18+
19+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2
20+
21+
# install NLP packages *mecab-ko & khai*
22+
RUN apt-get update && \
23+
apt-get install -y \
24+
openjdk-8-jdk \
25+
libasound2-dev \
26+
gfortran \
27+
automake \
28+
&& \
29+
cd /tmp && \
30+
curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
31+
tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
32+
cd mecab-0.996-ko-0.9.2 && \
33+
./configure && \
34+
make -j$(nproc) && \
35+
make check && \
36+
make install
37+
38+
RUN echo "Install mecab-ko-dic" && \
39+
cd /tmp && \
40+
ldconfig && \
41+
curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
42+
tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
43+
cd mecab-ko-dic-2.1.1-20180720 && \
44+
./autogen.sh && \
45+
./configure && \
46+
make -j$(nproc) && \
47+
sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \
48+
make install && \
49+
cd /tmp && \
50+
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
51+
python3 -m pip install /tmp/mecab-python-0.996
52+
53+
# OpenCV
54+
RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
55+
apt-get install -y \
56+
libgstreamer1.0-dev \
57+
libgstreamer-plugins-base1.0-dev \
58+
libgtk-3-dev \
59+
libtbb-dev \
60+
libatlas-base-dev \
61+
libdc1394-22-dev \
62+
libxvidcore-dev \
63+
libfaac-dev \
64+
libmp3lame-dev \
65+
libtheora-dev \
66+
libvorbis-dev \
67+
libxvidcore-dev \
68+
libopencore-amrnb-dev libopencore-amrwb-dev \
69+
libavresample-dev \
70+
x264 \
71+
libx264-dev \
72+
v4l-utils \
73+
libprotobuf-dev protobuf-compiler \
74+
libgoogle-glog-dev libgflags-dev \
75+
libgphoto2-dev \
76+
libeigen3-dev \
77+
libhdf5-dev \
78+
&& \
79+
apt-get clean && \
80+
rm -rf /var/lib/apt/lists/
81+
82+
WORKDIR /tmp
83+
ENV OPENCV_VERSION="4.5.2"
84+
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
85+
wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
86+
unzip ${OPENCV_VERSION}.zip && \
87+
unzip opencv-contrib.zip && \
88+
mkdir opencv-${OPENCV_VERSION}/cmake_binary && \
89+
cd opencv-${OPENCV_VERSION}/cmake_binary && \
90+
cmake \
91+
-DCMAKE_BUILD_TYPE=RELEASE \
92+
-D BUILD_TIFF=ON \
93+
-D BUILD_opencv_java=OFF \
94+
-D WITH_CUDA=ON \
95+
-D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
96+
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.2 \
97+
-D ENABLE_FAST_MATH=1 \
98+
-D CUDA_FAST_MATH=1 \
99+
-D WITH_CUBLAS=1 \
100+
-D WITH_OPENGL=ON \
101+
-D WITH_OPENCL=ON \
102+
-D WITH_IPP=ON \
103+
-D WITH_TBB=ON \
104+
-D WITH_EIGEN=ON \
105+
-D WITH_V4L=ON \
106+
-D BUILD_TESTS=OFF \
107+
-D BUILD_PERF_TESTS=OFF \
108+
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.2/modules" \
109+
-D CMAKE_BUILD_TYPE=RELEASE \
110+
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
111+
-D PYTHON_EXECUTABLE=$(which python3) \
112+
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
113+
-D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
114+
.. 2>&1 | tee cmake_messages.txt && \
115+
make -j$(nproc) && \
116+
make install && \
117+
cd /tmp && \
118+
python3 -m pip install --no-cache-dir opencv-python && \
119+
rm -fr opencv*
120+
121+
122+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
123+
apt-get update -y && \
124+
apt-get install -y nodejs
125+
126+
WORKDIR /tmp
127+
RUN git clone -q --branch=v0.3.13 git://github.com/xianyi/OpenBLAS.git && \
128+
cd OpenBLAS && \
129+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
130+
make install
131+
RUN git clone --recursive https://github.com/bodono/scs-python.git && \
132+
cd /tmp/scs-python && \
133+
python setup.py install --scs --gpu
134+
RUN mkdir -p /opt/oracle && \
135+
cd /opt/oracle && \
136+
apt-get clean && \
137+
rm -rf /var/lib/apt/lists/* && \
138+
apt-get update -y && \
139+
apt-get install -y --no-install-recommends libaio1 default-libmysqlclient-dev && \
140+
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \
141+
unzip instantclient-basiclite-linuxx64.zip && \
142+
rm -f instantclient-basiclite-linuxx64.zip && \
143+
cd /opt/oracle/instantclient* && \
144+
rm -f *jdbc* *occi* *mysql* *README *jar uidrvci genezi adrci && \
145+
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && \
146+
ldconfig
147+
148+
WORKDIR /tmp
149+
RUN python3 -m pip install --no-cache-dir \
150+
argon2_cffi==20.1.0
151+
COPY ./requirements.txt /tmp
152+
RUN python3 -m pip install --no-cache-dir -r requirements.txt && \
153+
rm -f /tmp/*.whl /tmp/requirements.txt
154+
ENV SCIPY_VERSION 1.6.0
155+
# Install scipy
156+
RUN cd /tmp && \
157+
git clone --branch=v${SCIPY_VERSION} --depth=1 https://github.com/scipy/scipy.git scipy && \
158+
cd scipy && \
159+
git checkout -b v${SCIPY_VERSION} && \
160+
cp site.cfg.example site.cfg && \
161+
pip uninstall -y typing && \
162+
python3 -m pip install .
163+
164+
165+
# install git-lfs
166+
WORKDIR /tmp
167+
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.12.1/git-lfs-linux-amd64-v2.12.1.tar.gz && \
168+
tar -zxf git-lfs-linux-amd64-v2.12.1.tar.gz && \
169+
bash install.sh && \
170+
rm -rf /tmp/*
171+
172+
COPY ./service-defs /etc/backend.ai/service-defs
173+
RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.7.3/code-server-3.7.3-linux-amd64.tar.gz | tar -C /usr/local/lib -xz && \
174+
mv /usr/local/lib/code-server-3.7.3-linux-amd64 /usr/local/lib/code-server-3.7.3 && \
175+
ln -s /usr/local/lib/code-server-3.7.3/bin/code-server /usr/local/bin/code-server
176+
# Install Open MPI
177+
RUN mkdir /tmp/openmpi && \
178+
cd /tmp/openmpi && \
179+
wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-4.0.5.tar.gz && \
180+
tar zxf openmpi-4.0.5.tar.gz && \
181+
cd openmpi-4.0.5 && \
182+
./configure --enable-orterun-prefix-by-default && \
183+
make -j $(nproc) all && \
184+
make install && \
185+
ldconfig && \
186+
rm -rf /tmp/openmpi*
187+
# Create a wrapper for OpenMPI to allow running as root by default
188+
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
189+
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
190+
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
191+
chmod a+x /usr/local/bin/mpirun
192+
193+
# Configure OpenMPI to run good defaults:
194+
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
195+
196+
RUN jupyter nbextensions_configurator enable && \
197+
jupyter contrib nbextension install && \
198+
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
199+
jupyter serverextension enable --py jupyterlab --sys-prefix && \
200+
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager && \
201+
jupyter labextension install --no-build @krassowski/jupyterlab-lsp && \
202+
jupyter serverextension enable --py jupyter_lsp && \
203+
jupyter labextension install --no-build @jupyterlab/toc && \
204+
jupyter nbextension enable execute_time/ExecuteTime && \
205+
jupyter nbextension enable toc2/main && \
206+
jupyter labextension install @pyviz/jupyterlab_pyviz && \
207+
jupyter labextension install @bokeh/jupyter_bokeh && \
208+
jupyter labextension install --no-build jupyterlab-nvdashboard && \
209+
jupyter lab build
210+
211+
RUN apt autoclean && \
212+
sed -i 's/source \/usr\/local\/nvm\/nvm.sh//' /etc/bash.bashrc && \
213+
rm -rf /var/lib/apt/lists/* && \
214+
rm -rf /root/.cache && \
215+
rm -rf /tmp/*
216+
217+
# Install ipython kernelspec
218+
RUN /usr/bin/python3 -m ipykernel install --display-name "Python 3.8 (NGC 21.03 / TensorFlow 1.15) on Backend.AI" && \
219+
cat /usr/local/share/jupyter/kernels/python3/kernel.json
220+
221+
# Backend.AI specifics
222+
LABEL ai.backend.kernelspec="1" \
223+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
224+
ai.backend.features="batch query uid-match user-input" \
225+
ai.backend.base-distro="ubuntu16.04" \
226+
ai.backend.accelerators="cuda" \
227+
ai.backend.resource.min.cpu="1" \
228+
ai.backend.resource.min.mem="1g" \
229+
ai.backend.resource.min.cuda.device=1 \
230+
ai.backend.resource.min.cuda.shares=0.1 \
231+
ai.backend.base-distro="ubuntu16.04" \
232+
ai.backend.runtime-type="python" \
233+
ai.backend.runtime-path="/usr/bin/python" \
234+
ai.backend.service-ports="ipython:pty:3000,jupyter:http:8080,jupyterlab:http:8090,vscode:http:8180,tensorboard:http:6006"
235+
236+
WORKDIR /home/work
237+
# vim: ft=dockerfile

0 commit comments

Comments
 (0)