|
| 1 | +FROM nvcr.io/nvidia/tensorflow:20.10-tf2-py3 |
| 2 | +# NVIDIA DIGITS runs on Python 3.6 |
| 3 | + |
| 4 | +RUN apt-get update && \ |
| 5 | + apt-get install -y libsm6 libxext6 libxrender-dev mercurial |
| 6 | + |
| 7 | +ENV DEBIAN_FRONTEND=noninteractive \ |
| 8 | + MPLBACKEND=Svg \ |
| 9 | + PYTHONUNBUFFERED=1 \ |
| 10 | + LD_LIBRARY_PATH="/usr/local/cuda/extras/CUPTI/lib64:/usr/local/cuda/lib64:/usr/local/nvidia/lib64:/usr/include/x86_64-linux-gnu" \ |
| 11 | + 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" \ |
| 12 | + mecab_dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic \ |
| 13 | + LANG=C.UTF-8 |
| 14 | + |
| 15 | +# install NLP packages *mecab-ko & khai* |
| 16 | +RUN apt-get update && \ |
| 17 | + apt-get install -y \ |
| 18 | + openjdk-8-jdk \ |
| 19 | + libasound2-dev \ |
| 20 | + gfortran \ |
| 21 | + automake \ |
| 22 | + && \ |
| 23 | + cd /tmp && \ |
| 24 | + curl -LO https://bitbucket.org/eunjeon/mecab-ko/downloads/mecab-0.996-ko-0.9.2.tar.gz && \ |
| 25 | + tar zxfv mecab-0.996-ko-0.9.2.tar.gz && \ |
| 26 | + cd mecab-0.996-ko-0.9.2 && \ |
| 27 | + ./configure && \ |
| 28 | + make -j$(nproc) && \ |
| 29 | + make check && \ |
| 30 | + make install |
| 31 | + |
| 32 | +RUN echo "Install mecab-ko-dic" && \ |
| 33 | + cd /tmp && \ |
| 34 | + ldconfig && \ |
| 35 | + curl -LO https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.1.1-20180720.tar.gz && \ |
| 36 | + tar -zxvf mecab-ko-dic-2.1.1-20180720.tar.gz && \ |
| 37 | + cd mecab-ko-dic-2.1.1-20180720 && \ |
| 38 | + ./autogen.sh && \ |
| 39 | + ./configure && \ |
| 40 | + make -j$(nproc) && \ |
| 41 | + sh -c 'echo "dicdir=/usr/local/lib/mecab/dic/mecab-ko-dic" > /usr/local/etc/mecabrc' && \ |
| 42 | + make install && \ |
| 43 | + cd /tmp && \ |
| 44 | + git clone https://bitbucket.org/eunjeon/mecab-python-0.996.git && \ |
| 45 | + python3 -m pip install /tmp/mecab-python-0.996 |
| 46 | + |
| 47 | +# OpenCV |
| 48 | +RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \ |
| 49 | + apt-get install -y \ |
| 50 | + libgstreamer1.0-dev \ |
| 51 | + libgstreamer-plugins-base1.0-dev \ |
| 52 | + libgtk-3-dev \ |
| 53 | + libtbb-dev \ |
| 54 | + libatlas-base-dev \ |
| 55 | + libdc1394-22-dev \ |
| 56 | + libxvidcore-dev \ |
| 57 | + libfaac-dev \ |
| 58 | + libmp3lame-dev \ |
| 59 | + libtheora-dev \ |
| 60 | + libvorbis-dev \ |
| 61 | + libxvidcore-dev \ |
| 62 | + libopencore-amrnb-dev libopencore-amrwb-dev \ |
| 63 | + libavresample-dev \ |
| 64 | + x264 \ |
| 65 | + libx264-dev \ |
| 66 | + v4l-utils \ |
| 67 | + libprotobuf-dev protobuf-compiler \ |
| 68 | + libgoogle-glog-dev libgflags-dev \ |
| 69 | + libgphoto2-dev \ |
| 70 | + libeigen3-dev \ |
| 71 | + libhdf5-dev \ |
| 72 | + && \ |
| 73 | + apt-get clean && \ |
| 74 | + rm -rf /var/lib/apt/lists/ |
| 75 | + |
| 76 | +WORKDIR /tmp |
| 77 | +ENV OPENCV_VERSION="4.4.0" |
| 78 | +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ |
| 79 | + wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ |
| 80 | + unzip ${OPENCV_VERSION}.zip && \ |
| 81 | + unzip opencv-contrib.zip && \ |
| 82 | + mkdir opencv-${OPENCV_VERSION}/cmake_binary && \ |
| 83 | + cd opencv-${OPENCV_VERSION}/cmake_binary && \ |
| 84 | + cmake \ |
| 85 | + -DCMAKE_BUILD_TYPE=RELEASE \ |
| 86 | + -D BUILD_TIFF=ON \ |
| 87 | + -D BUILD_opencv_java=OFF \ |
| 88 | + -D WITH_CUDA=ON \ |
| 89 | + -D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \ |
| 90 | + -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.1 \ |
| 91 | + -D ENABLE_FAST_MATH=1 \ |
| 92 | + -D CUDA_FAST_MATH=1 \ |
| 93 | + -D WITH_CUBLAS=1 \ |
| 94 | + -D WITH_OPENGL=ON \ |
| 95 | + -D WITH_OPENCL=ON \ |
| 96 | + -D WITH_IPP=ON \ |
| 97 | + -D WITH_TBB=ON \ |
| 98 | + -D WITH_EIGEN=ON \ |
| 99 | + -D WITH_V4L=ON \ |
| 100 | + -D BUILD_TESTS=OFF \ |
| 101 | + -D BUILD_PERF_TESTS=OFF \ |
| 102 | + -D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.4.0/modules" \ |
| 103 | + -D CMAKE_BUILD_TYPE=RELEASE \ |
| 104 | + -D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \ |
| 105 | + -D PYTHON_EXECUTABLE=$(which python3) \ |
| 106 | + -D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ |
| 107 | + -D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \ |
| 108 | + .. 2>&1 | tee cmake_messages.txt && \ |
| 109 | + make -j$(nproc) && \ |
| 110 | + make install && \ |
| 111 | + cd /tmp && \ |
| 112 | + python3 -m pip install --no-cache-dir opencv-python && \ |
| 113 | + rm -fr opencv* |
| 114 | + |
| 115 | +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2 |
| 116 | + |
| 117 | +WORKDIR /tmp |
| 118 | +RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \ |
| 119 | + python3 -m pip install --no-cache-dir -U setuptools pip |
| 120 | + |
| 121 | +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ |
| 122 | + apt-get update -y && \ |
| 123 | + apt-get install -y nodejs |
| 124 | + |
| 125 | +WORKDIR /tmp |
| 126 | +RUN git clone -q --branch=master git://github.com/xianyi/OpenBLAS.git && \ |
| 127 | + cd OpenBLAS && \ |
| 128 | + make DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=48 FC=gfortran && \ |
| 129 | + make install |
| 130 | +RUN git clone --recursive https://github.com/bodono/scs-python.git && \ |
| 131 | + cd /tmp/scs-python && \ |
| 132 | + python setup.py install --scs --gpu |
| 133 | + |
| 134 | +COPY ./numpy-1.18.5-cp36-cp36m-manylinux2010_x86_64.whl /tmp |
| 135 | +COPY ./pandas-1.0.4+4.g29edbab4a-cp36-cp36m-linux_x86_64.whl /tmp |
| 136 | +RUN python3 -m pip install --no-cache-dir \ |
| 137 | + Cython==0.29.21 \ |
| 138 | + tornado==6.0.4 \ |
| 139 | + pystan==2.19.1.1 \ |
| 140 | + pycairo==1.19.0 \ |
| 141 | + jupyter \ |
| 142 | + python-language-server[all] \ |
| 143 | + matplotlib==3.1.1 |
| 144 | +ENV SCIPY_VERSION 1.5.2 |
| 145 | +# Install scipy |
| 146 | +RUN cd /tmp && \ |
| 147 | + git clone --branch=v${SCIPY_VERSION} --depth=1 https://github.com/scipy/scipy.git scipy && \ |
| 148 | + cd scipy && \ |
| 149 | + git checkout -b v${SCIPY_VERSION} && \ |
| 150 | + cp site.cfg.example site.cfg && \ |
| 151 | + python3 -m pip install -U --no-cache-dir \ |
| 152 | + /tmp/numpy-1.18.5-cp36-cp36m-manylinux2010_x86_64.whl \ |
| 153 | + /tmp/pandas-1.0.4+4.g29edbab4a-cp36-cp36m-linux_x86_64.whl \ |
| 154 | + scikit-learn \ |
| 155 | + hypothesis \ |
| 156 | + && \ |
| 157 | + python3 setup.py install |
| 158 | + |
| 159 | +WORKDIR /tmp |
| 160 | +COPY ./requirements.20.08.txt /tmp |
| 161 | +RUN python3 -m pip install --no-cache-dir -r requirements.20.08.txt && \ |
| 162 | + python3 -m pip install --no-cache-dir tensorflow_model_analysis && \ |
| 163 | + rm -f /tmp/*.whl /tmp/requirements.20.08.txt |
| 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 | + rm -rf /var/lib/apt/lists/* && \ |
| 213 | + rm -rf /root/.cache && \ |
| 214 | + rm -rf /tmp/* |
| 215 | + |
| 216 | +# Install ipython kernelspec |
| 217 | +RUN /usr/bin/python3 -m ipykernel install --display-name "Python 3.6 (NGC 20.10 / TensorFlow 2.3) on Backend.AI" && \ |
| 218 | + cat /usr/local/share/jupyter/kernels/python3/kernel.json |
| 219 | + |
| 220 | +# Backend.AI specifics |
| 221 | +LABEL ai.backend.kernelspec="1" \ |
| 222 | + ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \ |
| 223 | + ai.backend.features="batch query uid-match user-input" \ |
| 224 | + ai.backend.base-distro="ubuntu16.04" \ |
| 225 | + ai.backend.accelerators="cuda" \ |
| 226 | + ai.backend.resource.min.cpu="1" \ |
| 227 | + ai.backend.resource.min.mem="1g" \ |
| 228 | + ai.backend.resource.min.cuda.device=1 \ |
| 229 | + ai.backend.resource.min.cuda.shares=0.1 \ |
| 230 | + ai.backend.base-distro="ubuntu16.04" \ |
| 231 | + ai.backend.runtime-type="python" \ |
| 232 | + ai.backend.runtime-path="/usr/bin/python" \ |
| 233 | + ai.backend.service-ports="ipython:pty:3000,jupyter:http:8080,jupyterlab:http:8090,vscode:http:8180,tensorboard:http:6006" |
| 234 | + |
| 235 | +WORKDIR /home/work |
| 236 | +# vim: ft=dockerfile |
0 commit comments