FROM ubuntu:20.04 RUN apt-get update \ && apt-get upgrade -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* LABEL maintainer="Amazon AI" LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true LABEL dlc_major_version="1" # prevent stopping by user interaction ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NONINTERACTIVE_SEEN true # Add arguments to achieve the version, python and url ARG PYTHON=python3 ARG PYTHON_VERSION=3.8.13 ARG PYTORCH_VERSION=1.5.1 ARG TORCHVISION_VERSION=0.6.1 ARG GRAPHVIZ_VERSION=0.13.2 ARG MMS_VERSION=1.1.8 ARG HEALTH_CHECK_VERSION=1.7.0 ARG MAMBA_VERSION=4.12.0-2 # See http://bugs.python.org/issue19846 ENV LANG C.UTF-8 ENV LD_LIBRARY_PATH /opt/conda/lib/:$LD_LIBRARY_PATH ENV PATH /opt/conda/bin:$PATH ENV SAGEMAKER_SERVING_MODULE sagemaker_pytorch_serving_container.serving:main ENV TEMP=/home/model-server/tmp RUN apt-get update \ && apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \ build-essential \ ca-certificates \ cmake \ curl \ emacs \ git \ krb5-user \ libkdb5-9 \ libsdl2-2.0-0 \ libgssapi-krb5-2 \ jq \ libgl1-mesa-glx \ libglib2.0-0 \ libgomp1 \ libibverbs-dev \ libmysofa1 \ libsm6 \ libtiff5 \ libxext6 \ libxrender-dev \ libzmq5 \ openjdk-8-jdk-headless \ vim \ wget \ unzip \ zlib1g-dev # Install OpenSSH. Allow OpenSSH to talk to containers without asking for confirmation RUN apt-get install -y --no-install-recommends \ openssh-client \ openssh-server \ && mkdir -p /var/run/sshd \ && cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new \ && echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new \ && mv /etc/ssh/ssh_config.new /etc/ssh/ssh_configs 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 \ python=$PYTHON_VERSION \ && /opt/conda/bin/conda install -y \ ruamel_yaml==0.15.80 \ cython==0.29.30 \ ipython==8.4.0 \ scipy==1.7.3 \ typing==3.7.4.3 \ parso==0.8.3 \ # Below 2 are included in miniconda base, but not mamba so need to install conda-content-trust \ charset-normalizer \ && /opt/conda/bin/conda update -y conda \ && /opt/conda/bin/conda clean -ya RUN conda install -y \ scikit-learn==1.1.1 \ pandas==1.4.3 \ h5py==3.7.0 \ requests==2.28.1 \ && conda clean -ya \ && /opt/conda/bin/conda config --set ssl_verify False \ && pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \ && ln -s /opt/conda/bin/pip /usr/local/bin/pip3 \ # Torchvision wheel must be installed first, so that PyTorch-EI framework is not overwritten. && pip install https://download.pytorch.org/whl/cpu/torchvision-0.6.1%2Bcpu-cp38-cp38-linux_x86_64.whl \ && pip install https://amazonei-pytorcheia.s3.amazonaws.com/releases/torcheia-1.0.0-cp38-cp38-manylinux1_x86_64.whl \ && pip install certifi \ && pip install graphviz==$GRAPHVIZ_VERSION \ && pip install multi-model-server==$MMS_VERSION \ && pip install opencv-python \ && pip install numpy==1.22.4 \ && pip install pillow==9.3.0 \ && pip install urllib3==1.26.11 \ # pyOpenSSL requires cryptography>=2.3 && pip install cryptography==39.0.1 RUN useradd -m model-server \ && mkdir -p /home/model-server/tmp \ && chown -R model-server /home/model-server COPY mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.py RUN pip install --no-cache-dir "sagemaker-pytorch-inference<2" 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.5.1/license.txt -o /license.txt RUN conda install -y -c conda-forge "pyyaml>=5.4,<5.5" \ && pip install -U \ "awscli<2" RUN wget https://amazonei-tools.s3.amazonaws.com/v${HEALTH_CHECK_VERSION}/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz -O /opt/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz \ && tar -xvf /opt/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz -C /opt/ \ && rm -rf /opt/ei_tools_${HEALTH_CHECK_VERSION}.tar.gz \ && chmod a+x /opt/ei_tools/bin/health_check \ && mkdir -p /opt/ei_health_check/bin \ && ln -s /opt/ei_tools/bin/health_check /opt/ei_health_check/bin/health_check \ && ln -s /opt/ei_tools/lib /opt/ei_health_check/lib COPY default_inference_handler.py /opt/conda/lib/python3.8/site-packages/sagemaker_pytorch_serving_container/default_inference_handler.py EXPOSE 8080 8081 ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"] CMD ["multi-model-server", "--start", "--mms-config", "/home/model-server/config.properties"]