Skip to content

Commit

Permalink
AWS Serverless update (#1115)
Browse files Browse the repository at this point in the history
* update deepsparse version

* cleanup
  • Loading branch information
InquestGeronimo committed Jul 12, 2023
1 parent c6aa08f commit f2d3296
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 203 deletions.
2 changes: 1 addition & 1 deletion examples/aws-serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ python endpoint.py create-realtime

#### Call Realtime Endpoint

After the endpoint has been staged (~3 minute), AWS SAM will provide your API Gateway endpoint URL in CLI. You can start making requests by passing this URL into the LambdaClient object. Afterwards, you can run inference by passing in your text input:
After the endpoint has been staged (~3 minutes), AWS SAM will provide your API Gateway endpoint URL in terminal. You can start making requests by passing this URL into the LambdaClient object. Afterwards, you can run inference by passing in your text input:

```python
from client import LambdaClient
Expand Down
3 changes: 1 addition & 2 deletions examples/aws-serverless/batch/app_inf/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
boto3>=1.18.34
https://github.com/neuralmagic/transformers/releases/download/v1.4/transformers-4.23.1-py3-none-any.whl
deepsparse>=1.4.0
deepsparse[transformers]>=1.5.2
20 changes: 6 additions & 14 deletions examples/aws-serverless/realtime/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
# Pull the base image with python 3.8 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.8
# Pull the base image with python 3.10 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.10.2023.07.11.09

ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY topo-four-core.json ./
ENV NM_ARCH_FILE=./topo-four-core.json

# Copy the earlier created requirements.txt file to the container
# Copy the requirements.txt file to the container
COPY requirements.txt ./

# Install the python requirements from requirements.txt
RUN python3 -m venv $VIRTUAL_ENV && \
pip install --no-cache-dir --upgrade pip && \
python3.8 -m pip install -r requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install -r requirements.txt

# Copy the earlier created app.py file to the container
COPY app.py ./

# Load the BERT model from SparseZoo and store it in the model directory
# Load model from SparseZoo and store it in the model directory
RUN mkdir model

# RUN sparsezoo.download zoo:nlp/question_answering/distilbert-none/pytorch/huggingface/squad/pruned80_quant-none-vnni --save-dir ./model
RUN sparsezoo.download zoo:nlp/sentiment_analysis/obert-base/pytorch/huggingface/sst2/pruned90_quant-none --save-dir ./model

# Set the CMD to your handler
Expand Down
3 changes: 1 addition & 2 deletions examples/aws-serverless/realtime/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
https://github.com/neuralmagic/transformers/releases/download/v1.4/transformers-4.23.1-py3-none-any.whl
deepsparse>=1.2.0
deepsparse[transformers]>=1.5.2
182 changes: 0 additions & 182 deletions examples/aws-serverless/realtime/app/topo-four-core.json

This file was deleted.

4 changes: 2 additions & 2 deletions examples/aws-serverless/realtime/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
ImageUri: deepsparseendpoint:python3.8-v1
ImageUri: deepsparseendpoint:python3.10-v1
MemorySize: 2000
Timeout: 300
Role: !GetAtt LambdaExecutionRole.Arn
Expand All @@ -21,7 +21,7 @@ Resources:
Metadata:
Dockerfile: Dockerfile
DockerContext: ./app
DockerTag: python3.8-v1
DockerTag: python3.10-v1

LambdaExecutionRole:
Type: AWS::IAM::Role
Expand Down

0 comments on commit f2d3296

Please sign in to comment.