Skip to content

Commit

Permalink
Add sagemaker compatible image (#322)
Browse files Browse the repository at this point in the history
chore(tgi): add sagemaker compatible image
  • Loading branch information
dacorvo authored Nov 13, 2023
1 parent d4154e7 commit b9a1ef2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ $(PACKAGE_DIST) $(PACKAGE_WHEEL): $(PACKAGE_FILES)
neuronx-tgi: $(PACKAGE_DIST)
docker build --rm -f text-generation-inference/Dockerfile --build-arg VERSION=$(VERSION) -t neuronx-tgi:$(VERSION) .

neuronx-tgi-sagemaker: $(PACKAGE_DIST)
docker build --rm -f text-generation-inference/Dockerfile --target sagemaker --build-arg VERSION=$(VERSION) -t neuronx-tgi:$(VERSION) .

# Creates example scripts from Transformers
transformers_examples:
rm -f examples/**/*.py
Expand Down
8 changes: 8 additions & 0 deletions text-generation-inference/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ COPY --from=builder /usr/src/target/release/text-generation-launcher /usr/local/
COPY --from=pyserver /pyserver/build/dist dist
RUN pip install dist/text-generation-server*.tar.gz

# AWS Sagemaker compatible image
FROM neuron as sagemaker

COPY text-generation-inference/sagemaker-entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]

# Final image
FROM neuron

Expand Down
17 changes: 17 additions & 0 deletions text-generation-inference/sagemaker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [[ -z "${HF_MODEL_ID}" ]]; then
echo "HF_MODEL_ID must be set"
exit 1
fi
export MODEL_ID="${HF_MODEL_ID}"

if [[ -n "${HF_MODEL_REVISION}" ]]; then
export REVISION="${HF_MODEL_REVISION}"
fi

if [[ -n "${HF_MODEL_TRUST_REMOTE_CODE}" ]]; then
export TRUST_REMOTE_CODE="${HF_MODEL_TRUST_REMOTE_CODE}"
fi

text-generation-launcher --port 8080

0 comments on commit b9a1ef2

Please sign in to comment.