From 8f7119f287e29fd2dbff31ec02663873b1becd61 Mon Sep 17 00:00:00 2001 From: Daniela Plascencia Date: Wed, 1 May 2019 14:02:25 -0500 Subject: [PATCH] DLRS release 1390 Signed-off-by: Daniela Plascencia --- stacks/dlrs/mkl/README.md | 2 +- stacks/dlrs/mkl/set_env.sh | 20 +++++++ stacks/dlrs/oss/README.md | 2 +- stacks/dlrs/pytorch/mkl/Dockerfile | 92 ++++++++++++++++++------------ stacks/dlrs/pytorch/mkl/README.md | 2 +- stacks/dlrs/pytorch/oss/README.md | 2 +- stacks/dlrs/releasenote.md | 2 +- 7 files changed, 81 insertions(+), 41 deletions(-) create mode 100755 stacks/dlrs/mkl/set_env.sh diff --git a/stacks/dlrs/mkl/README.md b/stacks/dlrs/mkl/README.md index 19b4256..cc1ac4a 100644 --- a/stacks/dlrs/mkl/README.md +++ b/stacks/dlrs/mkl/README.md @@ -14,4 +14,4 @@ docker build --no-cache -t clearlinux/stacks-dlrs-mkl . * `swupd_args` specifies [swupd update](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options) flags passed to the update during build. ->NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28560. +>NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28680. diff --git a/stacks/dlrs/mkl/set_env.sh b/stacks/dlrs/mkl/set_env.sh new file mode 100755 index 0000000..a9baf09 --- /dev/null +++ b/stacks/dlrs/mkl/set_env.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +echo "Sane defaults when using MKL_DNN optimized DLRS stack." +echo "We recommend you fine tune the exported env variables based on the workload" +echo "More details can be found at: https://github.com/IntelAI/models/blob/master/docs/general/tensorflow_serving/GeneralBestPractices.md" + + +# A good default setting for OMP theads is number of physical cores +physical_cores=$(lscpu | grep 'Core(s)' | head -1 | awk '{print $4}') +sockets=$(lscpu | grep 'Socket(s)' | head -1 | awk '{print $2}') +total_physical_cores=$((physical_cores * sockets)) +export OMP_NUM_THREADS=$total_physical_cores +# number of threads to use for a TensorFlow session, specifically +# when used for inference +export TENSORFLOW_SESSION_PARALLELISM=$((total_physical_cores / 4)) +export KMP_BLOCKTIME=2 +export KMP_AFFINITY=granularity=fine,verbose,compact,1,0 +# if available set intra_op and inter_op threads as well. +export INTRA_OP_PARALLELISM_THREADS=$total_physical_cores +export INTER_OP_PARALLELISM_THREADS=$sockets diff --git a/stacks/dlrs/oss/README.md b/stacks/dlrs/oss/README.md index f5448b1..42b8a98 100644 --- a/stacks/dlrs/oss/README.md +++ b/stacks/dlrs/oss/README.md @@ -14,4 +14,4 @@ docker build --no-cache -t clearlinux/stacks-dlrs-oss . * `swupd_args` specifies [swupd update](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options) flags passed to the update during build. ->NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28560. +>NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28680. diff --git a/stacks/dlrs/pytorch/mkl/Dockerfile b/stacks/dlrs/pytorch/mkl/Dockerfile index 6abdcec..6fea1ba 100644 --- a/stacks/dlrs/pytorch/mkl/Dockerfile +++ b/stacks/dlrs/pytorch/mkl/Dockerfile @@ -4,49 +4,34 @@ LABEL maintainer=otc-swstacks@intel.com ARG PYTHON_VERSION=3.7.1 ARG MINICONDA_VERSION=4.5.12 -ARG HOROVOD_VERSION=0.16.0 -ARG MKL_VERSION=2019.1 ARG swupd_args ENV PATH /opt/conda/bin:$PATH # update os and add pkgs RUN swupd update $swupd_args && \ - swupd bundle-add which git devpkg-opencv openssh-server sysadmin-basic devpkg-openmpi + swupd bundle-add which git \ + devpkg-opencv openssh-server \ + sysadmin-basic devpkg-openmpi # install miniconda and necessary build packages ADD https://repo.continuum.io/miniconda/Miniconda3-$MINICONDA_VERSION-Linux-x86_64.sh /tmp/miniconda.sh RUN chmod +x /tmp/miniconda.sh && \ /tmp/miniconda.sh -b -p /opt/conda && \ - conda install -y python=$PYTHON_VERSION \ - numpy pyyaml scipy ipython mkl=${MKL_VERSION} mkl-include=${MKL_VERSION} cython typing && \ - conda install -y gcc libgcc -c conda-forge -RUN pip --no-cache-dir install ninja + conda install -c anaconda -y python=$PYTHON_VERSION \ + pip=18.1 \ + setuptools=40.6.3 \ + six=1.12.0 \ + numpy=1.16.2 \ + pyyaml=5.1 \ + mkl=2019.1 \ + mkl-include=2019.1 \ + cython=0.29.6 \ + typing=3.6.4 \ + ninja=1.9.0 -# clone and build pytorch with -RUN mv /opt/conda/compiler_compat/ld /opt/conda/compiler_compat/ld.orig -RUN cd /tmp && git clone https://github.com/pytorch/pytorch.git -WORKDIR /tmp/pytorch -# includes patches for optimized ideep backend for inference -RUN git checkout 4ac91b2 &&\ - git submodule update --init -RUN CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" \ - BUILD_ONNX_PYTHON=ON \ - USE_OPENMP=ON \ - pip install -v . - -# install horovod and additional python packages for vision an notebook -RUN pip --no-cache-dir install torchvision -RUN pip --no-cache-dir install ipython ipykernel jupyter && \ - python -m ipykernel.kernelspec -RUN HOROVOD_WITH_TORCH=1 pip install --no-cache-dir horovod==${HOROVOD_VERSION} -RUN mv /opt/conda/compiler_compat/ld.orig /opt/conda/compiler_compat/ld - - -# setup onnx and helper packages for caffe2 -RUN conda install -y -c conda-forge onnx && \ - conda install libgcc=5.2.0 && \ - pip install --no-cache-dir future \ - hypothesis protobuf networkx opencv-python +RUN conda install -c conda-forge -y \ + gcc=4.8.5 \ + libgcc=7.2.0 #fix from:https://github.com/ContinuumIO/anaconda-issues/issues/5191 RUN \ @@ -54,10 +39,45 @@ RUN \ ln -sf libstdc++.so.6.0.25 libstdc++.so && \ ln -sf libstdc++.so.6.0.25 libstdc++.so.6 +# clone and build pytorch with +RUN mv /opt/conda/compiler_compat/ld /opt/conda/compiler_compat/ld.orig +RUN cd /tmp && git clone https://github.com/pytorch/pytorch.git +WORKDIR /tmp/pytorch +RUN git checkout 4ac91b2 &&\ + git submodule update --init +RUN CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" \ + BUILD_ONNX_PYTHON=ON \ + USE_OPENMP=ON \ + pip install -v . + +# torchvision and jupyter +RUN pip --no-cache-dir install \ + torchvision==0.2.2 \ + jupyterlab==0.35.4 \ + jupyterhub==0.9.4 \ + ipython==7.4.0 \ + ipykernel==5.1.0 && \ + python -m ipykernel install --user + +# install horovod +RUN HOROVOD_WITH_TORCH=1 pip install --no-cache-dir horovod==0.16.0 +RUN mv /opt/conda/compiler_compat/ld.orig /opt/conda/compiler_compat/ld + + +# setup onnx and helper packages for caffe2 +RUN conda install -c conda-forge -c anaconda -y \ + onnx=1.4.1 +RUN pip --no-cache-dir install \ + future==0.17.1 \ + hypothesis==4.14.0 \ + protobuf==3.7.0 \ + networkx==2.2 \ + opencv-python==4.0.0.21 + # clean up and init -RUN conda clean -typsy -RUN rm -fr /tmp/* +RUN conda clean -typsy &&\ + rm -fr /tmp/* WORKDIR /workspace -RUN chmod -R a+w /workspace -RUN echo "export PATH=$PATH" >> ~/.bashrc +RUN chmod -R a+w /workspace &&\ + echo "export PATH=$PATH" >> ~/.bashrc CMD /bin/bash && source ~/.bashrc diff --git a/stacks/dlrs/pytorch/mkl/README.md b/stacks/dlrs/pytorch/mkl/README.md index 1e0c395..a2de4a2 100644 --- a/stacks/dlrs/pytorch/mkl/README.md +++ b/stacks/dlrs/pytorch/mkl/README.md @@ -14,4 +14,4 @@ docker build --no-cache -t clearlinux/stacks-pytorch-mkl . * `swupd_args` specifies [swupd update](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options) flags passed to the update during build. ->NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28560. +>NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28680. diff --git a/stacks/dlrs/pytorch/oss/README.md b/stacks/dlrs/pytorch/oss/README.md index c3b5d5b..eca42ef 100644 --- a/stacks/dlrs/pytorch/oss/README.md +++ b/stacks/dlrs/pytorch/oss/README.md @@ -14,4 +14,4 @@ docker build --no-cache -t clearlinux/stacks-pytorch-oss . * `swupd_args` specifies [swupd update](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options) flags passed to the update during build. ->NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28560. +>NOTE: An empty `swupd_args` will default to Clear Linux OS latest version. Consider this when building from the Dockerfile, as an OS update will be performed. The docker image in this registry was built and validated using version 28680. diff --git a/stacks/dlrs/releasenote.md b/stacks/dlrs/releasenote.md index 477c693..d9c839c 100644 --- a/stacks/dlrs/releasenote.md +++ b/stacks/dlrs/releasenote.md @@ -9,7 +9,7 @@ To offer more flexibility, we are releasing multiple versions of the Deep Learni > **Note:** - Clear Linux will be automatically updated to the latest release version in the container. The minimum validated version of Clear Linux for this stack is 28560. + Clear Linux will be automatically updated to the latest release version in the container. The minimum validated version of Clear Linux for this stack is 28680. > **Note:** > For multi-node support, we include a registry with a set of jsonnet files to show integration with Kubeflow for deployment.