11# Build based on https://github.com/aws/deep-learning-containers/blob/master/huggingface/pytorch/inference/docker/2.1/py3/sdk2.18.0/Dockerfile.neuronx
2- FROM ubuntu:20 .04 as base
2+ FROM ubuntu:22 .04 AS base
33
44LABEL maintainer="Hugging Face"
55
6- ARG PYTHON=python3.10
7- ARG PYTHON_VERSION=3.10.12
8- ARG MAMBA_VERSION=23.1.0-4
9-
10- # Neuron SDK components version numbers
11- ARG NEURONX_FRAMEWORK_VERSION=2.1.2.2.1.0
12- ARG NEURONX_DISTRIBUTED_VERSION=0.7.0
13- ARG NEURONX_CC_VERSION=2.13.66.0
14- ARG NEURONX_TRANSFORMERS_VERSION=0.10.0.21
15- ARG NEURONX_COLLECTIVES_LIB_VERSION=2.20.22.0-c101c322e
16- ARG NEURONX_RUNTIME_LIB_VERSION=2.20.22.0-1b3ca6425
17- ARG NEURONX_TOOLS_VERSION=2.17.1.0
6+ ARG NEURONX_COLLECTIVES_LIB_VERSION=2.22.33.0-d2128d1aa
7+ ARG NEURONX_RUNTIME_LIB_VERSION=2.22.19.0-5856c0b42
8+ ARG NEURONX_TOOLS_VERSION=2.19.0.0
189
1910# HF ARGS
20- ARG OPTIMUM_NEURON_VERSION=0.0.23
11+ ARG OPTIMUM_NEURON_VERSION=0.0.28
2112
2213# See http://bugs.python.org/issue19846
23- ENV LANG C.UTF-8
24- ENV LD_LIBRARY_PATH /opt/aws/neuron/lib:/lib/x86_64-linux-gnu:/opt/conda/lib/:$LD_LIBRARY_PATH
25- ENV PATH /opt/conda/bin: /opt/aws/neuron/bin:$PATH
14+ ENV LANG= C.UTF-8
15+ ENV LD_LIBRARY_PATH= /opt/aws/neuron/lib:/lib/x86_64-linux-gnu:/opt/conda/lib/:$LD_LIBRARY_PATH
16+ ENV PATH= /opt/aws/neuron/bin:$PATH
2617
2718RUN apt-get update \
2819 && apt-get upgrade -y \
2920 && apt-get install -y --no-install-recommends software-properties-common \
30- && add-apt-repository ppa:openjdk-r/ppa \
3121 && apt-get update \
3222 && apt-get install -y --no-install-recommends \
3323 build-essential \
3424 apt-transport-https \
3525 ca-certificates \
3626 cmake \
3727 curl \
38- emacs \
3928 git \
4029 jq \
41- libgl1-mesa-glx \
42- libsm6 \
43- libxext6 \
44- libxrender-dev \
45- openjdk-11-jdk \
46- vim \
4730 wget \
4831 unzip \
4932 zlib1g-dev \
50- libcap-dev \
51- gpg-agent \
52- && rm -rf /var/lib/apt/lists/* \
53- && rm -rf /tmp/tmp* \
54- && apt-get clean
33+ gpg-agent
5534
56- RUN echo "deb https://apt.repos.neuron.amazonaws.com focal main" > /etc/apt/sources.list.d/neuron.list
35+ RUN echo "deb https://apt.repos.neuron.amazonaws.com jammy main" > /etc/apt/sources.list.d/neuron.list
5736RUN wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add -
5837
5938# Install Neuronx tools
6039RUN apt-get update \
6140 && apt-get install -y \
6241 aws-neuronx-tools=$NEURONX_TOOLS_VERSION \
6342 aws-neuronx-collectives=$NEURONX_COLLECTIVES_LIB_VERSION \
64- aws-neuronx-runtime-lib=$NEURONX_RUNTIME_LIB_VERSION \
65- && rm -rf /var/lib/apt/lists/* \
43+ aws-neuronx-runtime-lib=$NEURONX_RUNTIME_LIB_VERSION
44+
45+ RUN apt-get install -y \
46+ python3 \
47+ python3-pip \
48+ python-is-python3
49+
50+ RUN rm -rf /var/lib/apt/lists/* \
6651 && rm -rf /tmp/tmp* \
6752 && apt-get clean
6853
69- # https://github.com/docker-library/openjdk/issues/261 https://github.com/docker-library/openjdk/pull/263/files
70- RUN keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \
71- mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \
72- /var/lib/dpkg/info/ca-certificates-java.postinst configure;
73-
74- RUN curl -L -o ~/mambaforge.sh https://github.com/conda-forge/miniforge/releases/download/${MAMBA_VERSION}/Mambaforge-${MAMBA_VERSION}-Linux-x86_64.sh \
75- && chmod +x ~/mambaforge.sh \
76- && ~/mambaforge.sh -b -p /opt/conda \
77- && rm ~/mambaforge.sh \
78- && /opt/conda/bin/conda update -y conda \
79- && /opt/conda/bin/conda install -c conda-forge -y \
80- python=$PYTHON_VERSION \
81- pyopenssl \
82- cython \
83- mkl-include \
84- mkl \
85- botocore \
86- parso \
87- scipy \
88- typing \
89- # Below 2 are included in miniconda base, but not mamba so need to install
90- conda-content-trust \
91- charset-normalizer \
92- && /opt/conda/bin/conda update -y conda \
93- && /opt/conda/bin/conda clean -ya
94-
95- RUN conda install -c conda-forge \
96- scikit-learn \
97- h5py \
98- requests \
99- && conda clean -ya \
100- && pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \
101- && ln -s /opt/conda/bin/pip /usr/local/bin/pip3 \
102- && pip install --no-cache-dir "protobuf>=3.18.3,<4" setuptools==69.5.1 packaging
103-
54+ RUN pip install --no-cache-dir "protobuf>=3.18.3,<4" setuptools==69.5.1 packaging
55+
10456WORKDIR /
10557
10658# install Hugging Face libraries and its dependencies
107- RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com --no-cache-dir optimum-neuron[neuronx]==${OPTIMUM_NEURON_VERSION} \
59+ RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com --no-cache-dir optimum-neuron[neuronx]==${OPTIMUM_NEURON_VERSION} \
10860 && pip install --no-deps --no-cache-dir -U torchvision==0.16.*
10961
62+ # FIXME
63+ RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com git+https://github.com/huggingface/optimum-neuron.git@5237fb0ada643ba471f60ed3a5d2eef3b66e8e59
11064
11165COPY . .
112- # install wheel and setuptools
66+
11367RUN pip install --no-cache-dir -U pip ".[st]"
11468
11569# copy application
@@ -118,5 +72,7 @@ COPY src/huggingface_inference_toolkit/webservice_starlette.py webservice_starle
11872
11973# copy entrypoint and change permissions
12074COPY --chmod=0755 scripts/entrypoint.sh entrypoint.sh
75+ COPY --chmod=0755 scripts/inf2_env.py inf2_env.py
76+ COPY --chmod=0755 scripts/inf2_entrypoint.sh inf2_entrypoint.sh
12177
122- ENTRYPOINT ["bash", "-c", "./entrypoint .sh"]
78+ ENTRYPOINT ["bash", "-c", "./inf2_entrypoint .sh"]
0 commit comments