forked from aws/deep-learning-containers
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stabilityai_pytorch][inference] Stability AI Inference DLC (aws#3195)
Co-authored-by: arjkesh <[email protected]> Co-authored-by: Shantanu Tripathi <[email protected]>
- Loading branch information
1 parent
7264fac
commit 39083d3
Showing
14 changed files
with
444 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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 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
47 changes: 47 additions & 0 deletions
47
stabilityai/pytorch/inference/docker/2.0/py3/cu118/Dockerfile.gpu
This file contains 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,47 @@ | ||
FROM 763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-inference:2.0.1-gpu-py310-cu118-ubuntu20.04-sagemaker | ||
|
||
LABEL dlc_major_version="1" | ||
ARG PYTHON=python3 | ||
ARG XFORMERS_VERSION=0.0.20 | ||
|
||
# xformers must be installed from source due to the older version of python in the DLC | ||
RUN pip install ninja \ | ||
&& pip install -v -U git+https://github.com/facebookresearch/xformers.git@v${XFORMERS_VERSION}#egg=xformers | ||
|
||
ARG SGM_VERSION=0.1.0 | ||
|
||
# Install Stability Generative Models, at the moment the wheel install does not work so we need the full repo | ||
RUN cd /tmp \ | ||
&& git clone https://github.com/stability-ai/generative-models -b ${SGM_VERSION} \ | ||
&& cd generative-models \ | ||
&& pip install -r requirements/pt2.txt \ | ||
&& pip install . \ | ||
&& rm -rf /tmp/generative-models | ||
|
||
# Resolve pip check conflicts and other issues | ||
RUN pip install --no-cache-dir -U \ | ||
"awscli>=1.29.15" \ | ||
"boto3>=1.28.15" \ | ||
"certifi>=2023.07.22" \ | ||
"pyopenssl>=23.2.0" \ | ||
"cryptography>=41.0.2" \ | ||
"transformers>=4.23.0" | ||
|
||
# Configure Torchserve for large model loading | ||
ENV TS_DEFAULT_RESPONSE_TIMEOUT=1000 | ||
|
||
# Copy custom entrypoint, which can unpack cache files | ||
ENV HUGGINGFACE_HUB_CACHE=/tmp/cache/huggingface/hub | ||
ENV TRANSFORMERS_CACHE=/tmp/cache/huggingface/transformers | ||
COPY torchserve-entrypoint.py /usr/local/bin/dockerd-entrypoint.py | ||
RUN mkdir -p /tmp/cache/huggingface \ | ||
&& chmod +x /usr/local/bin/dockerd-entrypoint.py | ||
|
||
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* |
48 changes: 48 additions & 0 deletions
48
stabilityai/pytorch/inference/docker/build_artifacts/torchserve-stabilityai-entrypoint.py
This file contains 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,48 @@ | ||
# Copyright 2019-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
|
||
import os | ||
import shlex | ||
import subprocess | ||
import sys | ||
|
||
from sagemaker_inference import environment | ||
|
||
SAI_MODEL_CACHE_FILE = os.path.join( | ||
environment.model_dir, os.getenv("SAI_MODEL_CACHE_FILE", "stabilityai-model-cache.tar") | ||
) | ||
SAI_MODEL_CACHE_PATH = os.getenv("SAI_MODEL_CACHE_PATH", "/tmp/cache") | ||
SAI_MODEL_CACHE_STATUS_FILE = os.path.join(SAI_MODEL_CACHE_PATH, ".model-cache-unpacked") | ||
if os.path.exists(SAI_MODEL_CACHE_FILE) and not os.path.exists(SAI_MODEL_CACHE_STATUS_FILE): | ||
subprocess.check_call( | ||
[ | ||
"tar", | ||
"-x", | ||
"-z" if SAI_MODEL_CACHE_FILE.endswith(".gz") else "", | ||
"-f", | ||
SAI_MODEL_CACHE_FILE, | ||
"-C", | ||
SAI_MODEL_CACHE_PATH, | ||
] | ||
) | ||
|
||
if sys.argv[1] == "serve": | ||
from sagemaker_pytorch_serving_container import serving | ||
|
||
serving.main() | ||
else: | ||
subprocess.check_call(shlex.split(" ".join(sys.argv[1:]))) | ||
|
||
# prevent docker exit | ||
subprocess.call(["tail", "-f", "/dev/null"]) |
This file contains 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 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 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 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 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
Oops, something went wrong.