Skip to content

Commit b1a08f8

Browse files
committed
NGC Pytorch 21.06
1 parent f46e555 commit b1a08f8

File tree

1 file changed

+280
-0
lines changed

1 file changed

+280
-0
lines changed
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
FROM nvcr.io/nvidia/pytorch:21.06-py3
2+
# NVIDIA PyTorch with Python 3.8 (CONDA)
3+
4+
5+
6+
ENV DEBIAN_FRONTEND=noninteractive \
7+
MPLBACKEND=Svg \
8+
PIP_IGNORE_INSTALLED=0 \
9+
PYTHONUNBUFFERED=1 \
10+
LD_LIBRARY_PATH="/usr/local/cuda/compat/lib:/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/nvidia/lib64:/usr/include/x86_64-linux-gnu" \
11+
PATH="/usr/local/nvm/versions/node/v14.8.0/bin:/opt/conda/bin:/usr/local/mpi/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin:/opt/tensorrt/bin:/usr/local/src/lightgbm/LightGBM:/usr/local/bin/mecab" \
12+
mecab_dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic \
13+
CPLUS_INCLUDE_PATH=/usr/include/gdal \
14+
C_INCLUDE_PATH=/usr/include/gdal \
15+
LANG=C.UTF-8
16+
17+
RUN apt-get update && \
18+
apt-get install -y --no-install-recommends \
19+
automake \
20+
fonts-nanum \
21+
fonts-nanum-coding \
22+
fonts-nanum-extra \
23+
gfortran \
24+
htop \
25+
libasound2-dev \
26+
libatlas-base-dev \
27+
libavresample-dev \
28+
libdc1394-22-dev \
29+
libeigen3-dev \
30+
libfaac-dev \
31+
libgdal-dev \
32+
libgflags-dev \
33+
libgoogle-glog-dev \
34+
libgphoto2-dev \
35+
libgstreamer-plugins-base1.0-dev \
36+
libgstreamer1.0-dev \
37+
libgtk-3-dev \
38+
libhdf5-dev \
39+
libmp3lame-dev \
40+
libopenblas-dev \
41+
libopencore-amrnb-dev \
42+
libopencore-amrwb-dev \
43+
libprotobuf-dev \
44+
libtheora-dev \
45+
libvorbis-dev \
46+
libx264-dev \
47+
libxext6 \
48+
libxrender-dev \
49+
libxvidcore-dev \
50+
mercurial \
51+
ncurses-term \
52+
protobuf-compiler \
53+
v4l-utils \
54+
x264 \
55+
openjdk-8-jdk \
56+
libsm6 \
57+
libtbb-dev
58+
59+
60+
RUN update-alternatives --install /opt/conda/bin/python python /opt/conda/bin/python3 2
61+
62+
WORKDIR /tmp
63+
# install NLP packages *mecab-ko & khai*
64+
RUN curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \
65+
tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \
66+
cd mecab-0.996-ko-0.9.2 && \
67+
./configure && \
68+
make -j$(nproc) && \
69+
make check && \
70+
make install
71+
72+
RUN echo "Install mecab-ko-dic" && \
73+
cd /tmp && \
74+
ldconfig && \
75+
curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \
76+
tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \
77+
cd mecab-ko-dic-2.1.1-20180720 && \
78+
./autogen.sh && \
79+
./configure && \
80+
make -j$(nproc) && \
81+
sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \
82+
make install && \
83+
cd /tmp && \
84+
git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \
85+
python3 -m pip install /tmp/mecab-python-0.996
86+
87+
WORKDIR /tmp
88+
RUN curl https://bootstrap.pypa.io/get-pip.py | /opt/conda/bin/python3 && \
89+
/opt/conda/bin/python3 -m pip install --no-cache-dir -U setuptools pip
90+
91+
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
92+
apt-get update -y && \
93+
apt-get install -y nodejs
94+
95+
WORKDIR /tmp
96+
RUN git clone -q --branch=v0.3.14 git://github.com/xianyi/OpenBLAS.git && \
97+
cd OpenBLAS && \
98+
make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \
99+
make install
100+
RUN git clone --recursive https://github.com/bodono/scs-python.git && \
101+
cd /tmp/scs-python && \
102+
python setup.py install --scs --gpu
103+
104+
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir \
105+
Cython==0.29.22 \
106+
tornado==6.1 \
107+
pystan==3.0.1 \
108+
pycairo==1.20.0 \
109+
jupyter==1.0.0 \
110+
typeguard==2.11.1 \
111+
python-language-server[all] \
112+
matplotlib==3.4.1
113+
ENV SCIPY_VERSION 1.6.3
114+
# Install scipy
115+
RUN cd /tmp && \
116+
git clone --branch=v${SCIPY_VERSION} --depth=1 https://github.com/scipy/scipy.git scipy && \
117+
cd scipy && \
118+
git checkout -b v${SCIPY_VERSION} && \
119+
cp site.cfg.example site.cfg && \
120+
/opt/conda/bin/python3 -m pip install -U --no-cache-dir \
121+
numpy==1.20.2 \
122+
pandas==1.2.4 \
123+
scikit-learn==0.24.1 \
124+
hypothesis==6.8.5 \
125+
torchserve \
126+
jsonargparse \
127+
torchmetrics \
128+
pyDeprecate \
129+
fsspec[http]>=2021.05.0 \
130+
PyYAML>=5.1 \
131+
pretrainedmodels \
132+
cnn-finetune \
133+
keras4torch \
134+
pytorch-lightning \
135+
&& \
136+
python3 setup.py install
137+
138+
WORKDIR /tmp
139+
COPY ./requirements.txt /tmp
140+
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir --ignore-installed -r requirements.txt && \
141+
rm -f /tmp/*.whl /tmp/requirements.txt
142+
143+
# OpenCV
144+
WORKDIR /tmp
145+
ENV OPENCV_VERSION="4.5.2"
146+
RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \
147+
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
148+
wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
149+
unzip ${OPENCV_VERSION}.zip && \
150+
unzip opencv-contrib.zip && \
151+
mkdir opencv-${OPENCV_VERSION}/cmake_binary && \
152+
cd opencv-${OPENCV_VERSION}/cmake_binary && \
153+
cmake \
154+
-DCMAKE_BUILD_TYPE=RELEASE \
155+
-D BUILD_TIFF=ON \
156+
-D BUILD_opencv_java=OFF \
157+
-D WITH_CUDA=ON \
158+
-D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
159+
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.3 \
160+
-D ENABLE_FAST_MATH=1 \
161+
-D CUDA_FAST_MATH=1 \
162+
-D WITH_CUBLAS=1 \
163+
-D WITH_OPENGL=ON \
164+
-D WITH_OPENCL=ON \
165+
-D WITH_IPP=ON \
166+
-D WITH_TBB=ON \
167+
-D WITH_EIGEN=ON \
168+
-D WITH_V4L=ON \
169+
-D BUILD_TESTS=OFF \
170+
-D BUILD_PERF_TESTS=OFF \
171+
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.2/modules" \
172+
-D CMAKE_BUILD_TYPE=RELEASE \
173+
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
174+
-D PYTHON_EXECUTABLE=$(which python3) \
175+
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
176+
-D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
177+
.. 2>&1 | tee cmake_messages.txt && \
178+
make -j$(nproc) && \
179+
make install && \
180+
cd /tmp && \
181+
python3 -m pip install --no-cache-dir opencv-python && \
182+
rm -fr opencv*
183+
184+
# install git-lfs
185+
WORKDIR /tmp
186+
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v2.13.3/git-lfs-linux-amd64-v2.13.3.tar.gz && \
187+
tar -zxf git-lfs-linux-amd64-v2.13.3.tar.gz && \
188+
bash install.sh && \
189+
rm -rf /tmp/*
190+
191+
WORKDIR /tmp
192+
RUN git clone https://github.com/aristocratos/bashtop.git && \
193+
cd bashtop && \
194+
make install
195+
196+
RUN curl -fL https://github.com/cdr/code-server/releases/download/v3.9.3/code-server-3.9.3-linux-amd64.tar.gz | tar -C /usr/local/lib -xz && \
197+
mv /usr/local/lib/code-server-3.9.3-linux-amd64 /usr/local/lib/code-server-3.9.3 && \
198+
ln -s /usr/local/lib/code-server-3.9.3/bin/code-server /usr/local/bin/code-server
199+
200+
# Install Open MPI
201+
RUN mkdir /tmp/openmpi && \
202+
cd /tmp/openmpi && \
203+
wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.0.tar.gz && \
204+
tar zxf openmpi-4.1.0.tar.gz && \
205+
cd openmpi-4.1.0 && \
206+
./configure --enable-orterun-prefix-by-default && \
207+
make -j $(nproc) all && \
208+
make install && \
209+
ldconfig && \
210+
rm -rf /tmp/openmpi*
211+
# Create a wrapper for OpenMPI to allow running as root by default
212+
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
213+
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
214+
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
215+
chmod a+x /usr/local/bin/mpirun
216+
217+
# Configure OpenMPI to run good defaults:
218+
RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf
219+
220+
# Install Horovod, temporarily using CUDA stubs
221+
RUN ldconfig /usr/local/cuda/targets/x86_64-linux/lib/stubs && \
222+
HOROVOD_CUDA_HOME=$CONDA_PREFIX HOROVOD_GPU_ALLREDUCE=NCCL HOROVOD_GPU_BROADCAST=NCCL HOROVOD_NCCL_LINK=SHARED \
223+
HOROVOD_WITHOUT_TENSORFLOW=1 HOROVOD_WITH_PYTORCH=1 HOROVOD_WITHOUT_MXNET=1 \
224+
pip install --no-cache-dir horovod==0.21.3 && \
225+
ldconfig
226+
227+
RUN python3 -m pip install --no-cache-dir \
228+
mpi4py==3.0.3 \
229+
nni==2.1 \
230+
mlflow==1.18.0 \
231+
tensorboard-plugin-wit \
232+
scikit-nni==0.2.1
233+
234+
235+
RUN jupyter nbextensions_configurator enable && \
236+
jupyter contrib nbextension install && \
237+
jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
238+
jupyter serverextension enable --py jupyterlab --sys-prefix && \
239+
jupyter labextension install --no-build @jupyter-widgets/jupyterlab-manager && \
240+
jupyter labextension install --no-build @krassowski/jupyterlab-lsp && \
241+
jupyter serverextension enable --py jupyter_lsp && \
242+
jupyter labextension install --no-build @jupyterlab/toc && \
243+
jupyter nbextension enable execute_time/ExecuteTime && \
244+
jupyter nbextension enable toc2/main && \
245+
jupyter labextension install @pyviz/jupyterlab_pyviz && \
246+
jupyter labextension install @bokeh/jupyter_bokeh && \
247+
jupyter lab build
248+
249+
RUN apt autoclean && \
250+
sed -i 's/source \/usr\/local\/nvm\/nvm.sh//' /etc/bash.bashrc && \
251+
ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color && \
252+
rm -rf /var/lib/apt/lists/* && \
253+
rm -rf /root/.cache && \
254+
rm -rf /tmp/*
255+
256+
RUN /opt/conda/bin/python3 -m ipykernel install \
257+
--prefix=/opt/conda/ \
258+
--display-name "PyTorch 1.9 (NGC 21.03/Python 3.8 Conda) on Backend.AI" && \
259+
cat /opt/conda/share/jupyter/kernels/python3/kernel.json
260+
261+
# Backend.AI specifics
262+
COPY ./service-defs /etc/backend.ai/service-defs
263+
COPY ./runner-scripts/bootstrap.sh runner-scripts/setup_multinode.py /opt/container/
264+
265+
LABEL ai.backend.kernelspec="1" \
266+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
267+
ai.backend.features="batch query uid-match user-input" \
268+
ai.backend.base-distro="ubuntu16.04" \
269+
ai.backend.accelerators="cuda" \
270+
ai.backend.resource.min.cpu="1" \
271+
ai.backend.resource.min.mem="1g" \
272+
ai.backend.resource.min.cuda.device=1 \
273+
ai.backend.resource.min.cuda.shares=0.1 \
274+
ai.backend.base-distro="ubuntu16.04" \
275+
ai.backend.runtime-type="python" \
276+
ai.backend.runtime-path="/opt/conda/bin/python3" \
277+
ai.backend.service-ports="ipython:pty:3000,jupyter:http:8091,jupyterlab:http:8090,vscode:http:8180,tensorboard:http:6006,mlflow-ui:preopen:5000,nniboard:preopen:8080"
278+
279+
WORKDIR /home/work
280+
# vim: ft=dockerfile

0 commit comments

Comments
 (0)