FROM ubuntu:20.04 #SDK 1.17.1 has version 1. We skipped 1.18.0. LABEL dlc_major_version="2" LABEL maintainer="Amazon AI" LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true ARG PYTHON=python3.8 ARG PYTHON_VERSION=3.8.13 ARG TS_VERSION=0.5.3 ARG MAMBA_VERSION=4.12.0-2 # See http://bugs.python.org/issue19846 ENV LANG C.UTF-8 ENV LD_LIBRARY_PATH /lib/x86_64-linux-gnu:/opt/conda/lib/:$LD_LIBRARY_PATH ENV PATH /opt/conda/bin:/opt/aws/neuron/bin:$PATH ENV SAGEMAKER_SERVING_MODULE sagemaker_pytorch_serving_container.serving:main ENV TEMP=/home/model-server/tmp RUN apt-get update \ && apt-get upgrade -y \ && apt-get install -y --no-install-recommends software-properties-common \ && add-apt-repository ppa:openjdk-r/ppa \ && apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ apt-transport-https \ ca-certificates \ cmake \ curl \ emacs \ git \ jq \ libgl1-mesa-glx \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ openjdk-11-jdk \ vim \ wget \ unzip \ zlib1g-dev \ libcap-dev \ gpg-agent \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/tmp* \ && apt-get clean RUN echo "deb https://apt.repos.neuron.amazonaws.com focal main" > /etc/apt/sources.list.d/neuron.list RUN wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add - RUN apt-get update \ && apt-get install -y \ aws-neuronx-tools \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/tmp* \ && apt-get clean # https://github.com/docker-library/openjdk/issues/261 https://github.com/docker-library/openjdk/pull/263/files RUN keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \ mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \ /var/lib/dpkg/info/ca-certificates-java.postinst configure; RUN curl -L -o ~/mambaforge.sh https://github.com/conda-forge/miniforge/releases/download/${MAMBA_VERSION}/Mambaforge-${MAMBA_VERSION}-Linux-x86_64.sh \ && chmod +x ~/mambaforge.sh \ && ~/mambaforge.sh -b -p /opt/conda \ && rm ~/mambaforge.sh \ && /opt/conda/bin/conda install -c conda-forge -y \ python=$PYTHON_VERSION \ cython \ mkl-include \ mkl \ parso \ scipy \ typing \ # Below 2 are included in miniconda base, but not mamba so need to install conda-content-trust \ charset-normalizer \ # Upstream conda looks to have moved to 4.13 which is incompatible with mamba 0.22.1 and will fail the conda-forge installs. # having "conda update conda" before the "conda -c conda-forge" commands will automatically update conda to 4.13. # Moving conda update conda" after the "conda -c conda-forge" commands keep conda at 4.12 but will update other packages using # the current conda 4.12 && /opt/conda/bin/conda update -y conda \ && /opt/conda/bin/conda clean -ya RUN conda install -c conda-forge \ opencv \ scikit-learn \ h5py \ requests \ && conda clean -ya \ && pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \ && ln -s /opt/conda/bin/pip /usr/local/bin/pip3 \ && pip install packaging==20.4 \ enum-compat==0.0.3 \ numpy==1.20.3 \ ipython \ # pyOpenSSL requires cryptography>=2.3, but all versions <3.3 have vulnerabilities "cryptography>=3.3.2" RUN pip install --no-cache-dir -U \ scipy \ six \ # install PyYAML>=5.4 to avoid conflict with latest awscli "pyYAML>=5.4,<5.5" \ "pillow>=8.3" \ "awscli<2" \ # numpy 1.18.5 is installed as part of neuron-cc..so installing older version of pandas that depends on numpy pandas==1.4.0 \ boto3 RUN pip install neuron-cc[tensorflow] --extra-index-url https://pip.repos.neuron.amazonaws.com \ && pip install "torch-neuron>=1.12.1,<1.12.2" --extra-index-url https://pip.repos.neuron.amazonaws.com \ && pip install "protobuf<4" \ && pip install torchserve==$TS_VERSION \ && pip install --no-deps --no-cache-dir -U torchvision==0.13.1 \ && pip install torch-model-archiver==$TS_VERSION RUN useradd -m model-server \ && mkdir -p /home/model-server/tmp /opt/ml/model \ && chown -R model-server /home/model-server /opt/ml/model COPY neuron-entrypoint.py /usr/local/bin/dockerd-entrypoint.py COPY neuron-monitor.sh /usr/local/bin/neuron-monitor.sh COPY torchserve-neuron.sh /usr/local/bin/entrypoint.sh COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.py \ && chmod +x /usr/local/bin/neuron-monitor.sh \ && chmod +x /usr/local/bin/entrypoint.sh ADD https://raw.githubusercontent.com/aws/deep-learning-containers/master/src/deep_learning_container.py /usr/local/bin/deep_learning_container.py RUN chmod +x /usr/local/bin/deep_learning_container.py RUN pip install --no-cache-dir "sagemaker-pytorch-inference==2.0.8" RUN HOME_DIR=/root \ && curl -o ${HOME_DIR}/oss_compliance.zip https://aws-dlinfra-utilities.s3.amazonaws.com/oss_compliance.zip \ && unzip ${HOME_DIR}/oss_compliance.zip -d ${HOME_DIR}/ \ && cp ${HOME_DIR}/oss_compliance/test/testOSSCompliance /usr/local/bin/testOSSCompliance \ && chmod +x /usr/local/bin/testOSSCompliance \ && chmod +x ${HOME_DIR}/oss_compliance/generate_oss_compliance.sh \ && ${HOME_DIR}/oss_compliance/generate_oss_compliance.sh ${HOME_DIR} ${PYTHON} \ && rm -rf ${HOME_DIR}/oss_compliance* RUN curl https://aws-dlc-licenses.s3.amazonaws.com/pytorch-1.10/license.txt -o /license.txt EXPOSE 8080 8081 ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"] CMD ["/usr/local/bin/entrypoint.sh"]