|
| 1 | +FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu16.04 |
| 2 | +# NCCL_VERSION=2.4.7, CUDNN_VERSION=7.6.2.24 |
| 3 | +LABEL maintainer="Amazon AI" |
| 4 | + |
| 5 | +ARG PYTHON_VERSION=2.7 |
| 6 | +ARG PYTORCH_VERSION=1.3.1 |
| 7 | +ARG TORCHVISION_VERSION=0.4.2 |
| 8 | +ARG MMS_VERSION=1.0.8 |
| 9 | + |
| 10 | +# See http://bugs.python.org/issue19846 |
| 11 | +ENV LANG C.UTF-8 |
| 12 | +ENV LD_LIBRARY_PATH /opt/conda/lib/:$LD_LIBRARY_PATH |
| 13 | +ENV PATH /opt/conda/bin:$PATH |
| 14 | +ENV SAGEMAKER_SERVING_MODULE sagemaker_pytorch_serving_container.serving:main |
| 15 | +ENV TEMP=/home/model-server/tmp |
| 16 | + |
| 17 | +RUN apt-get update \ |
| 18 | + && apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \ |
| 19 | + build-essential \ |
| 20 | + build-essential \ |
| 21 | + ca-certificates \ |
| 22 | + cmake \ |
| 23 | + curl \ |
| 24 | + git \ |
| 25 | + jq \ |
| 26 | + libgl1-mesa-glx \ |
| 27 | + libglib2.0-0 \ |
| 28 | + libgomp1 \ |
| 29 | + libibverbs-dev \ |
| 30 | + libsm6 \ |
| 31 | + libxext6 \ |
| 32 | + libxrender-dev \ |
| 33 | + openjdk-8-jdk-headless \ |
| 34 | + vim \ |
| 35 | + wget \ |
| 36 | + zlib1g-dev |
| 37 | + |
| 38 | +# Install OpenSSH, Allow OpenSSH to talk to containers without asking for confirmation |
| 39 | +RUN apt-get install -y --no-install-recommends \ |
| 40 | + openssh-client openssh-server \ |
| 41 | + && mkdir -p /var/run/sshd \ |
| 42 | + && cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new \ |
| 43 | + && echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new \ |
| 44 | + && mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config |
| 45 | + |
| 46 | +RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ |
| 47 | + && chmod +x ~/miniconda.sh \ |
| 48 | + && ~/miniconda.sh -b -p /opt/conda \ |
| 49 | + && rm ~/miniconda.sh \ |
| 50 | + && /opt/conda/bin/conda update conda \ |
| 51 | + && /opt/conda/bin/conda install -y \ |
| 52 | + python=$PYTHON_VERSION \ |
| 53 | + cython==0.29.12 \ |
| 54 | + ipython==5.8.0 \ |
| 55 | + mkl-include==2019.4 \ |
| 56 | + mkl==2019.4 \ |
| 57 | + numpy==1.16.4 \ |
| 58 | + scipy==1.2.1 \ |
| 59 | + typing==3.7.4 \ |
| 60 | + && /opt/conda/bin/conda clean -ya |
| 61 | + |
| 62 | + |
| 63 | +RUN conda install -c \ |
| 64 | + pytorch magma-cuda100 \ |
| 65 | + && conda install -c \ |
| 66 | + conda-forge \ |
| 67 | + awscli==1.16.210 \ |
| 68 | + opencv==4.0.1 \ |
| 69 | + && conda install -y scikit-learn==0.20.3 \ |
| 70 | + h5py==2.9.0 \ |
| 71 | + pandas==0.24.2 \ |
| 72 | + pillow==6.1.0 \ |
| 73 | + requests==2.22.0 \ |
| 74 | + && conda install -c \ |
| 75 | + pytorch \ |
| 76 | + cudatoolkit=10.0 \ |
| 77 | + pytorch==$PYTORCH_VERSION \ |
| 78 | + torchvision==$TORCHVISION_VERSION \ |
| 79 | + && conda clean -ya \ |
| 80 | + && /opt/conda/bin/conda config --set ssl_verify False \ |
| 81 | + && pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \ |
| 82 | + && pip install mxnet-model-server==$MMS_VERSION |
| 83 | + |
| 84 | +RUN useradd -m model-server \ |
| 85 | + && mkdir -p /home/model-server/tmp \ |
| 86 | + && chown -R model-server /home/model-server |
| 87 | + |
| 88 | +COPY docker/$PYTORCH_VERSION/py2/mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py |
| 89 | +COPY docker/$PYTORCH_VERSION/py2/config.properties /home/model-server |
| 90 | +COPY src/sagemaker_pytorch_serving_container/deep_learning_container.py /usr/local/bin/deep_learning_container.py |
| 91 | + |
| 92 | +RUN chmod +x /usr/local/bin/dockerd-entrypoint.py \ |
| 93 | + && chmod +x /usr/local/bin/deep_learning_container.py |
| 94 | + |
| 95 | +# Install OpenSSH for MPI to communicate between containers, Allow OpenSSH to talk to containers without asking for confirmation |
| 96 | +RUN apt-get install -y --no-install-recommends \ |
| 97 | + openssh-client openssh-server \ |
| 98 | + && mkdir -p /var/run/sshd \ |
| 99 | + && cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new \ |
| 100 | + && echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new \ |
| 101 | + && mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config |
| 102 | + |
| 103 | +# RUN pip install --no-cache-dir 'opencv-python>=4.0,<4.1' |
| 104 | + |
| 105 | +COPY dist/sagemaker_pytorch_serving_container-1.2-py2.py3-none-any.whl /sagemaker_pytorch_serving_container-1.2-py2.py3-none-any.whl |
| 106 | +RUN pip install --no-cache-dir \ |
| 107 | + /sagemaker_pytorch_serving_container-1.2-py2.py3-none-any.whl \ |
| 108 | + && rm /sagemaker_pytorch_serving_container-1.2-py2.py3-none-any.whl |
| 109 | + |
| 110 | +EXPOSE 8080 8081 |
| 111 | +ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"] |
| 112 | +CMD ["mxnet-model-server", "--start", "--mms-config", "/home/model-server/config.properties"] |
0 commit comments