Skip to content

Commit 8c3562d

Browse files
authored
update inferentia2 image (#106)
* Dockerfile inf2 -> use ubuntu 22.04 20.04 is reaching end of support this year anyway remove some unused dependencies for the inference web service to run Signed-off-by: Raphael Glon <[email protected]> * Inf2 hf endpoints docker image Signed-off-by: Raphael Glon <[email protected]> * inf2: docker image update - + fix broken dep install (kenlm) Signed-off-by: Raphael Glon <[email protected]> * inf2_env.py wrapper: env var consistency fix use the same HF_MODEL_ID env var as the main server Signed-off-by: Raphael Glon <[email protected]> --------- Signed-off-by: Raphael Glon <[email protected]> Co-authored-by: Raphael Glon <[email protected]>
1 parent 9767220 commit 8c3562d

File tree

3 files changed

+276
-68
lines changed

3 files changed

+276
-68
lines changed

dockerfiles/pytorch/Dockerfile.inf2

+23-68
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,69 @@
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

44
LABEL 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.12.313
156
ARG NEURONX_COLLECTIVES_LIB_VERSION=2.22.33.0-d2128d1aa
167
ARG NEURONX_RUNTIME_LIB_VERSION=2.22.19.0-5856c0b42
178
ARG NEURONX_TOOLS_VERSION=2.19.0.0
189

19-
2010
# HF ARGS
2111
ARG OPTIMUM_NEURON_VERSION=0.0.28
2212

2313
# See http://bugs.python.org/issue19846
24-
ENV LANG C.UTF-8
25-
ENV LD_LIBRARY_PATH /opt/aws/neuron/lib:/lib/x86_64-linux-gnu:/opt/conda/lib/:$LD_LIBRARY_PATH
26-
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
2717

2818
RUN apt-get update \
2919
&& apt-get upgrade -y \
3020
&& apt-get install -y --no-install-recommends software-properties-common \
31-
&& add-apt-repository ppa:openjdk-r/ppa \
3221
&& apt-get update \
3322
&& apt-get install -y --no-install-recommends \
3423
build-essential \
3524
apt-transport-https \
3625
ca-certificates \
3726
cmake \
3827
curl \
39-
emacs \
4028
git \
4129
jq \
42-
libgl1-mesa-glx \
43-
libsm6 \
44-
libxext6 \
45-
libxrender-dev \
46-
openjdk-11-jdk \
47-
vim \
4830
wget \
4931
unzip \
5032
zlib1g-dev \
51-
libcap-dev \
52-
gpg-agent \
53-
&& rm -rf /var/lib/apt/lists/* \
54-
&& rm -rf /tmp/tmp* \
55-
&& apt-get clean
33+
gpg-agent
5634

57-
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
5836
RUN wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add -
5937

6038
# Install Neuronx tools
6139
RUN apt-get update \
6240
&& apt-get install -y \
6341
aws-neuronx-tools=$NEURONX_TOOLS_VERSION \
6442
aws-neuronx-collectives=$NEURONX_COLLECTIVES_LIB_VERSION \
65-
aws-neuronx-runtime-lib=$NEURONX_RUNTIME_LIB_VERSION \
66-
&& 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/* \
6751
&& rm -rf /tmp/tmp* \
6852
&& apt-get clean
6953

70-
# https://github.com/docker-library/openjdk/issues/261 https://github.com/docker-library/openjdk/pull/263/files
71-
RUN keytool -importkeystore -srckeystore /etc/ssl/certs/java/cacerts -destkeystore /etc/ssl/certs/java/cacerts.jks -deststoretype JKS -srcstorepass changeit -deststorepass changeit -noprompt; \
72-
mv /etc/ssl/certs/java/cacerts.jks /etc/ssl/certs/java/cacerts; \
73-
/var/lib/dpkg/info/ca-certificates-java.postinst configure;
74-
75-
RUN curl -L -o ~/mambaforge.sh https://github.com/conda-forge/miniforge/releases/download/${MAMBA_VERSION}/Mambaforge-${MAMBA_VERSION}-Linux-x86_64.sh \
76-
&& chmod +x ~/mambaforge.sh \
77-
&& ~/mambaforge.sh -b -p /opt/conda \
78-
&& rm ~/mambaforge.sh \
79-
&& /opt/conda/bin/conda update -y conda \
80-
&& /opt/conda/bin/conda install -c conda-forge -y \
81-
python=$PYTHON_VERSION \
82-
pyopenssl \
83-
cython \
84-
mkl-include \
85-
mkl \
86-
botocore \
87-
parso \
88-
scipy \
89-
typing \
90-
# Below 2 are included in miniconda base, but not mamba so need to install
91-
conda-content-trust \
92-
charset-normalizer \
93-
&& /opt/conda/bin/conda update -y conda \
94-
&& /opt/conda/bin/conda clean -ya
95-
96-
RUN conda install -c conda-forge \
97-
scikit-learn \
98-
h5py \
99-
requests \
100-
&& conda clean -ya \
101-
&& pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \
102-
&& ln -s /opt/conda/bin/pip /usr/local/bin/pip3 \
103-
&& pip install --no-cache-dir "protobuf>=3.18.3,<4" setuptools==69.5.1 packaging
104-
54+
RUN pip install --no-cache-dir "protobuf>=3.18.3,<4" setuptools==69.5.1 packaging
55+
10556
WORKDIR /
10657

10758
# install Hugging Face libraries and its dependencies
108-
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} \
10960
&& pip install --no-deps --no-cache-dir -U torchvision==0.16.*
11061

62+
# FIXME
63+
RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com git+https://github.com/huggingface/optimum-neuron.git@5237fb0ada643ba471f60ed3a5d2eef3b66e8e59
11164

11265
COPY . .
113-
# install wheel and setuptools
66+
11467
RUN pip install --no-cache-dir -U pip ".[st]"
11568

11669
# copy application
@@ -119,5 +72,7 @@ COPY src/huggingface_inference_toolkit/webservice_starlette.py webservice_starle
11972

12073
# copy entrypoint and change permissions
12174
COPY --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
12277

123-
ENTRYPOINT ["bash", "-c", "./entrypoint.sh"]
78+
ENTRYPOINT ["bash", "-c", "./inf2_entrypoint.sh"]

scripts/inf2_entrypoint.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e -o pipefail -u
3+
4+
export ENV_FILEPATH=$(mktemp)
5+
6+
trap "rm -f ${ENV_FILEPATH}" EXIT
7+
8+
touch $ENV_FILEPATH
9+
10+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
11+
12+
${SCRIPT_DIR}/inf2_env.py $@
13+
14+
source $ENV_FILEPATH
15+
16+
rm -f $ENV_FILEPATH
17+
18+
exec ${SCRIPT_DIR}/entrypoint.sh $@

0 commit comments

Comments
 (0)