|
| 1 | +# Labup/Python-xxx Base kernel 19.10 to support Intel MKL |
| 2 | + |
| 3 | +## Base kernel Intel Distributed Python 2019.04 with Ubuntu 18.04 |
| 4 | +## Support Intel MKL 19.04 |
| 5 | +## Support TF-hub 0.5.0 |
| 6 | +## Support OpenCV 4.1.0 |
| 7 | +## Support Jupyter notebook extension |
| 8 | + |
| 9 | +FROM ubuntu:18.04 |
| 10 | + |
| 11 | +MAINTAINER Mario Cho " [email protected]" |
| 12 | + |
| 13 | +RUN apt-get update && \ |
| 14 | + apt-get install -y --no-install-recommends \ |
| 15 | + gcc g++ make \ |
| 16 | + libssl-dev \ |
| 17 | + libfreetype6-dev \ |
| 18 | + libhdf5-serial-dev \ |
| 19 | + libzmq3-dev \ |
| 20 | + pkg-config \ |
| 21 | + rsync \ |
| 22 | + software-properties-common \ |
| 23 | + zip unzip \ |
| 24 | + zlib1g-dev \ |
| 25 | + imagemagick \ |
| 26 | + graphviz \ |
| 27 | + cmake \ |
| 28 | + rsync \ |
| 29 | + sed \ |
| 30 | + swig \ |
| 31 | + git-core \ |
| 32 | + libcurl3-dev \ |
| 33 | + && \ |
| 34 | + rm -rf /var/lib/apt/lists/* |
| 35 | + |
| 36 | +RUN apt update -y && \ |
| 37 | + apt install -y --no-install-recommends \ |
| 38 | + apt-transport-https \ |
| 39 | + ca-certificates \ |
| 40 | + curl \ |
| 41 | + wget \ |
| 42 | + gnupg2 \ |
| 43 | + libexpat-dev \ |
| 44 | + && \ |
| 45 | + wget --no-check-certificate https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \ |
| 46 | + apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \ |
| 47 | + wget --no-check-certificate https://apt.repos.intel.com/setup/intelproducts.list -O /etc/apt/sources.list.d/intelproducts.list && \ |
| 48 | + sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' && \ |
| 49 | + sh -c 'echo deb https://apt.repos.intel.com/ipp all main > /etc/apt/sources.list.d/intel-ipp.list' && \ |
| 50 | + sh -c 'echo deb https://apt.repos.intel.com/tbb all main > /etc/apt/sources.list.d/intel-tbb.list' && \ |
| 51 | + sh -c 'echo deb https://apt.repos.intel.com/daal all main > /etc/apt/sources.list.d/intel-daal.list' && \ |
| 52 | + sh -c 'echo deb https://apt.repos.intel.com/mpi all main > /etc/apt/sources.list.d/intel-mpi.list' && \ |
| 53 | + sh -c 'echo deb https://apt.repos.intel.com/intelpython binary/ > /etc/apt/sources.list.d/intelpython.list' && \ |
| 54 | + apt-get update -y && \ |
| 55 | + apt -y install --no-install-recommends \ |
| 56 | + gcc g++ gfortran cpio git \ |
| 57 | + && \ |
| 58 | + wget -q http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15540/l_mkl_2019.4.243.tgz && \ |
| 59 | + tar -xzf l_mkl_2019.4.243.tgz && \ |
| 60 | + cd l_mkl_2019.4.243 && \ |
| 61 | + sed -i 's/ACCEPT_EULA=decline/ACCEPT_EULA=accept/g' silent.cfg && \ |
| 62 | + sed -i 's/ARCH_SELECTED=ALL/ARCH_SELECTED=INTEL64/g' silent.cfg && \ |
| 63 | + sed -i 's/COMPONENTS=DEFAULTS/COMPONENTS=;intel-comp-l-all-vars__noarch;intel-comp-nomcu-vars__noarch;intel-openmp__x86_64;intel-tbb-libs__x86_64;intel-mkl-common__noarch;intel-mkl-installer-license__noarch;intel-mkl-core__x86_64;intel-mkl-core-rt__x86_64;intel-mkl-doc__noarch;intel-mkl-doc-ps__noarch;intel-mkl-gnu__x86_64;intel-mkl-gnu-rt__x86_64;intel-mkl-common-ps__noarch;intel-mkl-core-ps__x86_64;intel-mkl-common-c__noarch;intel-mkl-core-c__x86_64;intel-mkl-common-c-ps__noarch;intel-mkl-tbb__x86_64;intel-mkl-tbb-rt__x86_64;intel-mkl-gnu-c__x86_64;intel-mkl-common-f__noarch;intel-mkl-core-f__x86_64;intel-mkl-gnu-f-rt__x86_64;intel-mkl-gnu-f__x86_64;intel-mkl-f95-common__noarch;intel-mkl-f__x86_64;intel-mkl-psxe__noarch;intel-psxe-common__noarch;intel-psxe-common-doc__noarch;intel-compxe-pset/g' silent.cfg && \ |
| 64 | + ./install.sh -s silent.cfg && \ |
| 65 | + cd .. && \ |
| 66 | + rm -rf * && \ |
| 67 | + rm -rf /opt/intel/.*.log /opt/intel/compilers_and_libraries_2019.4.243/licensing && \ |
| 68 | + echo "/opt/intel/mkl/lib/intel64" >> /etc/ld.so.conf.d/intel.conf && \ |
| 69 | + ldconfig && \ |
| 70 | + echo "source /opt/intel/mkl/bin/mklvars.sh intel64" >> /etc/bash.bashrc |
| 71 | + |
| 72 | +RUN apt-get update -y && \ |
| 73 | + apt-get install -y software-properties-common && \ |
| 74 | + add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main" && \ |
| 75 | + apt-get update -y && \ |
| 76 | + apt-get install -y \ |
| 77 | + ca-certificates \ |
| 78 | + gcc g++ make \ |
| 79 | + gfortran \ |
| 80 | + vim \ |
| 81 | + cmake \ |
| 82 | + yasm \ |
| 83 | + pkg-config \ |
| 84 | + xz-utils \ |
| 85 | + wget curl git-core \ |
| 86 | + vim-tiny bzip2 zip unzip \ |
| 87 | + libssl-dev \ |
| 88 | + libmpdec2 \ |
| 89 | + proj-bin libproj-dev \ |
| 90 | + libgeos-dev libgeos++-dev \ |
| 91 | + mime-support \ |
| 92 | + libpq-dev \ |
| 93 | + libjasper-dev \ |
| 94 | + libtiff-dev \ |
| 95 | + libjpeg-dev \ |
| 96 | + libpng-dev \ |
| 97 | + libavcodec-dev \ |
| 98 | + libavformat-dev \ |
| 99 | + libswscale-dev \ |
| 100 | + libxine2-dev \ |
| 101 | + libv4l-dev |
| 102 | + |
| 103 | +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ |
| 104 | + apt-get update -y && \ |
| 105 | + apt-get install -y nodejs |
| 106 | + |
| 107 | +RUN ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h && \ |
| 108 | + apt-get install -y \ |
| 109 | + libgstreamer1.0-dev \ |
| 110 | + libgstreamer-plugins-base1.0-dev \ |
| 111 | + libgtk-3-dev \ |
| 112 | + libtbb-dev \ |
| 113 | + libatlas-base-dev \ |
| 114 | + libdc1394-22-dev \ |
| 115 | + libxvidcore-dev \ |
| 116 | + libfaac-dev \ |
| 117 | + libmp3lame-dev \ |
| 118 | + libtheora-dev \ |
| 119 | + libvorbis-dev \ |
| 120 | + libxvidcore-dev \ |
| 121 | + libopencore-amrnb-dev libopencore-amrwb-dev \ |
| 122 | + libavresample-dev \ |
| 123 | + x264 \ |
| 124 | + libx264-dev \ |
| 125 | + v4l-utils \ |
| 126 | + libprotobuf-dev protobuf-compiler \ |
| 127 | + libgoogle-glog-dev libgflags-dev \ |
| 128 | + libgphoto2-dev \ |
| 129 | + libeigen3-dev \ |
| 130 | + libhdf5-dev \ |
| 131 | + && \ |
| 132 | + apt-get clean && \ |
| 133 | + rm -rf /var/lib/apt/lists/ |
| 134 | + |
| 135 | +ENV PYTHONUNBUFFERED=1 \ |
| 136 | + PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ |
| 137 | + LANG=C.UTF-8 |
| 138 | + |
| 139 | +# Install numpy with MKL |
| 140 | +RUN curl https://bootstrap.pypa.io/get-pip.py | python3 && \ |
| 141 | + python3 -m pip install --no-cache-dir -U setuptools pip && \ |
| 142 | + python3 -m pip install --no-cache-dir wheel && \ |
| 143 | + python3 -m pip install --no-cache-dir h5py && \ |
| 144 | + python3 -m pip install --no-cache-dir Cython && \ |
| 145 | + python3 -m pip install --no-cache-dir pyzmq simplejson msgpack-python uvloop && \ |
| 146 | + python3 -m pip install --no-cache-dir aiozmq dataclasses tabulate && \ |
| 147 | + python3 -m pip install --no-cache-dir namedlist six "python-dateutil>=2" && \ |
| 148 | + python3 -m pip install --no-cache-dir versioneer && \ |
| 149 | + python3 -m pip install --no-cache-dir pyproj Cartopy && \ |
| 150 | + python3 -m pip install --no-cache-dir pandas && \ |
| 151 | + python3 -m pip install --no-cache-dir seaborn && \ |
| 152 | + python3 -m pip install --no-cache-dir networkx cvxpy && \ |
| 153 | + python3 -m pip install --no-cache-dir scikit-learn scikit-image && \ |
| 154 | + python3 -m pip install --no-cache-dir pygments && \ |
| 155 | + python3 -m pip install --no-cache-dir future && \ |
| 156 | + python3 -m pip install --no-cache-dir tensorwatch |
| 157 | + |
| 158 | +WORKDIR /tmp |
| 159 | +ENV OPENCV_VERSION="4.1.0" |
| 160 | +RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \ |
| 161 | + wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \ |
| 162 | + unzip ${OPENCV_VERSION}.zip && \ |
| 163 | + unzip opencv-contrib.zip && \ |
| 164 | + mkdir opencv-${OPENCV_VERSION}/cmake_binary && \ |
| 165 | + cd opencv-${OPENCV_VERSION}/cmake_binary && \ |
| 166 | + cmake \ |
| 167 | + -DCMAKE_BUILD_TYPE=RELEASE \ |
| 168 | + -D BUILD_TIFF=ON \ |
| 169 | + -D BUILD_opencv_java=OFF \ |
| 170 | + -D WITH_CUDA=OFF \ |
| 171 | + -D ENABLE_FAST_MATH=1 \ |
| 172 | + -D CUDA_FAST_MATH=1 \ |
| 173 | + -D WITH_CUBLAS=1 \ |
| 174 | + -D WITH_OPENGL=ON \ |
| 175 | + -D WITH_OPENCL=ON \ |
| 176 | + -D WITH_IPP=ON \ |
| 177 | + -D WITH_TBB=ON \ |
| 178 | + -D WITH_EIGEN=ON \ |
| 179 | + -D WITH_V4L=ON \ |
| 180 | + -D BUILD_TESTS=OFF \ |
| 181 | + -D BUILD_PERF_TESTS=OFF \ |
| 182 | + -D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.1.0/modules" \ |
| 183 | + -D CMAKE_BUILD_TYPE=RELEASE \ |
| 184 | + -D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \ |
| 185 | + -D PYTHON_EXECUTABLE=$(which python3) \ |
| 186 | + -D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ |
| 187 | + -D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \ |
| 188 | + .. 2>&1 | tee cmake_messages.txt && \ |
| 189 | + make -j${nproc} && \ |
| 190 | + make install && \ |
| 191 | + cd /tmp && \ |
| 192 | + rm -fr opencv* |
| 193 | + |
| 194 | +COPY policy.yml /etc/backend.ai/jail/policy.yml |
| 195 | + |
| 196 | +# Jupyter notebook extension |
| 197 | +RUN mkdir -p /home/work/.jupyter/nbextension |
| 198 | +WORKDIR /home/work/.jupyter/nbextension |
| 199 | + |
| 200 | +RUN python3 -m pip install --no-cache-dir opencv-python |
| 201 | + |
| 202 | +RUN python3 -m pip install --no-cache-dir pystan && \ |
| 203 | + python3 -m pip install --no-cache-dir fbprophet && \ |
| 204 | + python3 -m pip install --no-cache-dir jupyter && \ |
| 205 | + python3 -m pip install --no-cache-dir ipython && \ |
| 206 | + python3 -m pip install --no-cache-dir ipywidgets && \ |
| 207 | + python3 -m pip install --no-cache-dir jupyterlab && \ |
| 208 | + python3 -m pip install --no-cache-dir jupyterthemes && \ |
| 209 | + python3 -m pip install --no-cache-dir jupyter-js-widgets-nbextension && \ |
| 210 | + python3 -m pip install --no-cache-dir jupyter_contrib_nbextensions && \ |
| 211 | + python3 -m pip install --no-cache-dir jupyter_nbextensions_configurator && \ |
| 212 | + python3 -m pip install --no-cache-dir matplotlib bokeh && \ |
| 213 | + rm -rf /root/.cache && \ |
| 214 | + rm -f /tmp/*.whl |
| 215 | + |
| 216 | +# python alternative support |
| 217 | +RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 2 |
| 218 | + |
| 219 | +RUN jupyter nbextensions_configurator enable && \ |
| 220 | + jupyter contrib nbextension install && \ |
| 221 | + jupyter nbextension enable --py --sys-prefix widgetsnbextension && \ |
| 222 | + jupyter contrib nbextension install && \ |
| 223 | + jupyter serverextension enable --py jupyterlab --sys-prefix && \ |
| 224 | + jupyter labextension install @jupyter-widgets/jupyterlab-manager && \ |
| 225 | + git clone https://github.com/lambdalisue/jupyter-vim-binding vim_binding && \ |
| 226 | + jupyter nbextension enable /home/work/.jupyter/nbextension/vim_binding/vim_binding |
| 227 | + |
| 228 | +WORKDIR /home/work |
0 commit comments