|
| 1 | +# Copyright (c) 2020-2021 Intel Corporation |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# ============================================================================ |
| 15 | +# |
| 16 | +# THIS IS A GENERATED DOCKERFILE. |
| 17 | +# |
| 18 | +# This file was assembled from multiple pieces, whose use is documented |
| 19 | +# throughout. Please refer to the TensorFlow dockerfiles documentation |
| 20 | +# for more information. |
| 21 | + |
| 22 | +ARG PYTORCH_IMAGE="model-zoo" |
| 23 | +ARG PYTORCH_TAG="pytorch-ipex-spr" |
| 24 | + |
| 25 | +FROM ${PYTORCH_IMAGE}:${PYTORCH_TAG} AS intel-optimized-pytorch |
| 26 | + |
| 27 | +# Build Torch Vision |
| 28 | +ARG TORCHVISION_VERSION=v0.8.0 |
| 29 | + |
| 30 | +RUN source ~/anaconda3/bin/activate pytorch && \ |
| 31 | + git clone https://github.com/pytorch/vision && \ |
| 32 | + cd vision && \ |
| 33 | + git checkout ${TORCHVISION_VERSION} && \ |
| 34 | + python setup.py install |
| 35 | + |
| 36 | +RUN source ~/anaconda3/bin/activate pytorch && \ |
| 37 | + pip install matplotlib Pillow pycocotools && \ |
| 38 | + pip install yacs opencv-python cityscapesscripts transformers && \ |
| 39 | + conda install -y libopenblas psutil && \ |
| 40 | + cd /workspace/installs && \ |
| 41 | + wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.7.90/gperftools-2.7.90.tar.gz && \ |
| 42 | + tar -xzf gperftools-2.7.90.tar.gz && \ |
| 43 | + cd gperftools-2.7.90 && \ |
| 44 | + ./configure --prefix=$HOME/.local && \ |
| 45 | + make && \ |
| 46 | + make install && \ |
| 47 | + rm -rf /workspace/installs/ |
| 48 | + |
| 49 | +ARG PACKAGE_DIR=model_packages |
| 50 | + |
| 51 | +ARG PACKAGE_NAME="pytorch-spr-maskrcnn-inference" |
| 52 | + |
| 53 | +ARG MODEL_WORKSPACE |
| 54 | + |
| 55 | +# ${MODEL_WORKSPACE} and below needs to be owned by root:root rather than the current UID:GID |
| 56 | +# this allows the default user (root) to work in k8s single-node, multi-node |
| 57 | +RUN umask 002 && mkdir -p ${MODEL_WORKSPACE} && chgrp root ${MODEL_WORKSPACE} && chmod g+s+w,o+s+r ${MODEL_WORKSPACE} |
| 58 | + |
| 59 | +ADD --chown=0:0 ${PACKAGE_DIR}/${PACKAGE_NAME}.tar.gz ${MODEL_WORKSPACE} |
| 60 | + |
| 61 | +RUN chown -R root ${MODEL_WORKSPACE}/${PACKAGE_NAME} && chgrp -R root ${MODEL_WORKSPACE}/${PACKAGE_NAME} && chmod -R g+s+w ${MODEL_WORKSPACE}/${PACKAGE_NAME} && find ${MODEL_WORKSPACE}/${PACKAGE_NAME} -type d | xargs chmod o+r+x |
| 62 | + |
| 63 | +WORKDIR ${MODEL_WORKSPACE}/${PACKAGE_NAME} |
| 64 | + |
| 65 | +ARG MASKRCNN_DIR="/workspace/pytorch-spr-maskrcnn-inference/models/maskrcnn" |
| 66 | + |
| 67 | +RUN source ~/anaconda3/bin/activate pytorch && \ |
| 68 | + cd ${MASKRCNN_DIR} && \ |
| 69 | + cd maskrcnn-benchmark && \ |
| 70 | + python setup.py install && \ |
| 71 | + pip install onnx |
| 72 | + |
| 73 | +FROM intel-optimized-pytorch AS release |
| 74 | +COPY --from=intel-optimized-pytorch /root/anaconda3 /root/anaconda3 |
| 75 | +COPY --from=intel-optimized-pytorch /workspace/lib/ /workspace/lib/ |
| 76 | +COPY --from=intel-optimized-pytorch /root/.local/ /root/.local/ |
| 77 | + |
| 78 | +ENV DNNL_MAX_CPU_ISA="AVX512_CORE_AMX" |
| 79 | + |
| 80 | +ENV PATH="~/anaconda3/bin:${PATH}" |
| 81 | +ENV LD_PRELOAD="/workspace/lib/jemalloc/lib/libjemalloc.so:$LD_PRELOAD" |
| 82 | +ENV MALLOC_CONF="oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000" |
| 83 | +ENV BASH_ENV=/root/.bash_profile |
| 84 | +WORKDIR /workspace/ |
| 85 | +RUN yum install -y numactl mesa-libGL && \ |
| 86 | + yum clean all && \ |
| 87 | + echo "source activate pytorch" >> /root/.bash_profile |
0 commit comments