Skip to content

Commit 8225190

Browse files
committed
Change Model server tp Torchserve for PytTorch Inference
1 parent c4e7abc commit 8225190

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed
File renamed without changes.

src/sagemaker_pytorch_serving_container/serving.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
from subprocess import CalledProcessError
1616

1717
from retrying import retry
18-
from sagemaker_inference import model_server
18+
from sagemaker_inference import torchserve
1919

2020
from sagemaker_pytorch_serving_container import handler_service
2121

22-
HANDLER_SERVICE = handler_service.__name__
22+
HANDLER_SERVICE = handler_service.__file__
2323

2424

2525
def _retry_if_error(exception):
@@ -32,7 +32,7 @@ def _start_model_server():
3232
# there's a race condition that causes the model server command to
3333
# sometimes fail with 'bad address'. more investigation needed
3434
# retry starting mms until it's ready
35-
model_server.start_model_server(handler_service=HANDLER_SERVICE)
35+
torchserve.start_model_server(handler_service=HANDLER_SERVICE)
3636

3737

3838
def main():

test/container/1.5.0/Dockerfile.pytorch

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@ FROM pytorch/pytorch:1.5-cuda10.1-cudnn7-runtime
33
LABEL com.amazonaws.sagemaker.capabilities.accept-bind-to-port=true
44
LABEL com.amazonaws.sagemaker.capabilities.multi-models=true
55

6-
ARG MMS_VERSION=1.0.8
6+
ARG TS_VERSION=0.1.1
77

88
ENV SAGEMAKER_SERVING_MODULE sagemaker_pytorch_serving_container.serving:main
99
ENV TEMP=/home/model-server/tmp
1010

1111
RUN apt-get update \
12+
&& apt-get install -y --no-install-recommends software-properties-common \
13+
&& add-apt-repository ppa:openjdk-r/ppa \
14+
&& apt-get update \
1215
&& apt-get install -y --no-install-recommends \
1316
libgl1-mesa-glx \
1417
libglib2.0-0 \
1518
libsm6 \
1619
libxext6 \
1720
libxrender-dev \
18-
openjdk-8-jdk-headless \
21+
openjdk-11-jdk \
1922
&& rm -rf /var/lib/apt/lists/*
2023

2124
RUN conda install -c conda-forge opencv==4.0.1 \
2225
&& ln -s /opt/conda/bin/pip /usr/local/bin/pip3
2326

24-
RUN pip install mxnet-model-server==$MMS_VERSION
27+
RUN pip install torchserve==$TS_VERSION \
28+
&& pip install torch-model-archiver==$TS_VERSION
2529

2630
COPY dist/sagemaker_pytorch_inference-*.tar.gz /sagemaker_pytorch_inference.tar.gz
2731
RUN pip install --no-cache-dir /sagemaker_pytorch_inference.tar.gz && \
@@ -31,11 +35,11 @@ RUN useradd -m model-server \
3135
&& mkdir -p /home/model-server/tmp \
3236
&& chown -R model-server /home/model-server
3337

34-
COPY artifacts/mms-entrypoint.py /usr/local/bin/dockerd-entrypoint.py
38+
COPY artifacts/ts-entrypoint.py /usr/local/bin/dockerd-entrypoint.py
3539
COPY artifacts/config.properties /home/model-server
3640

3741
RUN chmod +x /usr/local/bin/dockerd-entrypoint.py
3842

3943
EXPOSE 8080 8081
4044
ENTRYPOINT ["python", "/usr/local/bin/dockerd-entrypoint.py"]
41-
CMD ["mxnet-model-server", "--start", "--mms-config", "/home/model-server/config.properties"]
45+
CMD ["torchserve", "--start", "--ts-config", "/home/model-server/config.properties", "--model-store", "/home/model-server/"]

test/unit/test_serving.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
from mock import patch
1616

1717

18-
@patch('sagemaker_inference.model_server.start_model_server')
18+
@patch('sagemaker_inference.torchserve.start_model_server')
1919
def test_hosting_start(start_model_server):
2020
from sagemaker_pytorch_serving_container import serving
2121

2222
serving.main()
23-
24-
start_model_server.assert_called_with(
25-
handler_service='sagemaker_pytorch_serving_container.handler_service')
23+
start_model_server.assert_called()

0 commit comments

Comments
 (0)