-
Notifications
You must be signed in to change notification settings - Fork 17
[Inf2] Add Optimum Neuron support for Encoder models #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
78059ea
init
philschmid 8db395e
tests
philschmid dbe3abc
make style happy
philschmid 68f1876
refactor logging
philschmid 857c9b0
docker stuff
philschmid 45628ea
added ci action for inf2 images
philschmid f95d374
docker example
philschmid b4e1c41
adding tests
philschmid 63ce438
fix styling
philschmid a004819
fix ruff
philschmid 1a0d55f
fix unittests
philschmid a8d8078
fix tests
philschmid a41e05a
make style
philschmid 026827b
add container logs
philschmid bcac708
local container logs
philschmid 5a59a1f
retry
philschmid c3d2400
update time
philschmid 4a3bbb2
reduce parallelism
philschmid c398bb4
add rertries for flakyness
philschmid 2185d4a
style
philschmid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,4 +179,6 @@ model | |
tests/tmp | ||
tmp/ | ||
act.sh | ||
.act | ||
.act | ||
tmp* | ||
log-* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Build based on https://github.com/aws/deep-learning-containers/blob/master/huggingface/pytorch/inference/docker/2.1/py3/sdk2.18.0/Dockerfile.neuronx | ||
FROM ubuntu:20.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FROM ubuntu:22.04 or 24:04 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its what AWS uses. We should stick to the image the use. Using 22.04 lead to errors in the past with neuron. |
||
|
||
LABEL maintainer="Hugging Face" | ||
|
||
ARG PYTHON=python3.10 | ||
ARG PYTHON_VERSION=3.10.12 | ||
ARG MAMBA_VERSION=23.1.0-4 | ||
|
||
# Neuron SDK components version numbers | ||
ARG NEURONX_FRAMEWORK_VERSION=2.1.2.2.1.0 | ||
ARG NEURONX_DISTRIBUTED_VERSION=0.7.0 | ||
ARG NEURONX_CC_VERSION=2.13.66.0 | ||
ARG NEURONX_TRANSFORMERS_VERSION=0.10.0.21 | ||
ARG NEURONX_COLLECTIVES_LIB_VERSION=2.20.22.0-c101c322e | ||
ARG NEURONX_RUNTIME_LIB_VERSION=2.20.22.0-1b3ca6425 | ||
ARG NEURONX_TOOLS_VERSION=2.17.1.0 | ||
|
||
# HF ARGS | ||
ARG OPTIMUM_NEURON_VERSION=0.0.23 | ||
|
||
# See http://bugs.python.org/issue19846 | ||
ENV LANG C.UTF-8 | ||
ENV LD_LIBRARY_PATH /opt/aws/neuron/lib:/lib/x86_64-linux-gnu:/opt/conda/lib/:$LD_LIBRARY_PATH | ||
ENV PATH /opt/conda/bin:/opt/aws/neuron/bin:$PATH | ||
|
||
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 \ | ||
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 - | ||
|
||
# Install Neuronx tools | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
aws-neuronx-tools=$NEURONX_TOOLS_VERSION \ | ||
aws-neuronx-collectives=$NEURONX_COLLECTIVES_LIB_VERSION \ | ||
aws-neuronx-runtime-lib=$NEURONX_RUNTIME_LIB_VERSION \ | ||
&& 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 update -y conda \ | ||
&& /opt/conda/bin/conda install -c conda-forge -y \ | ||
python=$PYTHON_VERSION \ | ||
pyopenssl \ | ||
cython \ | ||
mkl-include \ | ||
mkl \ | ||
botocore \ | ||
parso \ | ||
scipy \ | ||
typing \ | ||
# 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 -c conda-forge \ | ||
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 --no-cache-dir "protobuf>=3.18.3,<4" setuptools==69.5.1 packaging | ||
|
||
WORKDIR / | ||
|
||
# install Hugging Face libraries and its dependencies | ||
RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com --no-cache-dir optimum-neuron[neuronx]==${OPTIMUM_NEURON_VERSION} \ | ||
&& pip install --no-deps --no-cache-dir -U torchvision==0.16.* | ||
|
||
|
||
COPY . . | ||
# install wheel and setuptools | ||
RUN pip install --no-cache-dir -U pip ".[st]" | ||
|
||
# copy application | ||
COPY src/huggingface_inference_toolkit huggingface_inference_toolkit | ||
COPY src/huggingface_inference_toolkit/webservice_starlette.py webservice_starlette.py | ||
|
||
# copy entrypoint and change permissions | ||
COPY --chmod=0755 scripts/entrypoint.sh entrypoint.sh | ||
|
||
ENTRYPOINT ["bash", "-c", "./entrypoint.sh"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.