Skip to content

Commit d5eb754

Browse files
authored
doc: add documentation for image_uri serverless use case (#3022)
1 parent 46684a7 commit d5eb754

File tree

8 files changed

+77
-21
lines changed

8 files changed

+77
-21
lines changed

doc/overview.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,28 @@ to configure or manage the underlying infrastructure. After you trained a model,
12261226
Serverless endpoint and then invoke the endpoint with the model to get inference results back. More information about
12271227
SageMaker Serverless Inference can be found in the `AWS documentation <https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints.html>`__.
12281228

1229+
For using SageMaker Serverless Inference, if you plan to use any of the SageMaker-provided container or Bring Your Own Container
1230+
model, you will need to pass ``image_uri``. An example to use ``image_uri`` for creating MXNet model:
1231+
1232+
.. code:: python
1233+
1234+
from sagemaker.mxnet import MXNetModel
1235+
import sagemaker
1236+
1237+
role = sagemaker.get_execution_role()
1238+
1239+
# create MXNet Model Class
1240+
mxnet_model = MXNetModel(
1241+
model_data="s3://my_bucket/pretrained_model/model.tar.gz", # path to your trained sagemaker model
1242+
role=role, # iam role with permissions to create an Endpoint
1243+
entry_point="inference.py",
1244+
image_uri="763104351884.dkr.ecr.us-west-2.amazonaws.com/mxnet-inference:1.4.1-cpu-py3" # image wanted to use
1245+
)
1246+
1247+
For more Amazon SageMaker provided algorithms and containers image paths, please check this page: `Amazon SageMaker provided
1248+
algorithms and Deep Learning Containers <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
1249+
After creating model using ``image_uri``, you can then follow the steps below to create serverless endpoint.
1250+
12291251
To deploy serverless endpoint, you will need to create a ``ServerlessInferenceConfig``.
12301252
If you create ``ServerlessInferenceConfig`` without specifying its arguments, the default ``MemorySizeInMB`` will be **2048** and
12311253
the default ``MaxConcurrency`` will be **5** :
@@ -1254,6 +1276,14 @@ Then use the ``ServerlessInferenceConfig`` in the estimator's ``deploy()`` metho
12541276
# Deploys the model that was generated by fit() to a SageMaker serverless endpoint
12551277
serverless_predictor = estimator.deploy(serverless_inference_config=serverless_config)
12561278
1279+
Or directly using model's ``deploy()`` method to deploy a serverless endpoint:
1280+
1281+
.. code:: python
1282+
1283+
# Deploys the model to a SageMaker serverless endpoint
1284+
serverless_predictor = model.deploy(serverless_inference_config=serverless_config)
1285+
1286+
12571287
After deployment is complete, you can use predictor's ``predict()`` method to invoke the serverless endpoint just like
12581288
real-time endpoints:
12591289

src/sagemaker/chainer/model.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,14 @@ def __init__(
9999
file which should be executed as the entry point to model
100100
hosting. If ``source_dir`` is specified, then ``entry_point``
101101
must point to a file located at the root of ``source_dir``.
102-
image_uri (str): A Docker image URI (default: None). If not specified, a
103-
default image for Chainer will be used. If ``framework_version``
104-
or ``py_version`` are ``None``, then ``image_uri`` is required. If
105-
also ``None``, then a ``ValueError`` will be raised.
102+
image_uri (str): A Docker image URI (default: None). In serverless
103+
inferece, it is required. More image information can be found in
104+
`Amazon SageMaker provided algorithms and Deep Learning Containers
105+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
106+
In instance based inference, if not specified, a default image for
107+
Chainer will be used. If ``framework_version`` or ``py_version``
108+
are ``None``, then ``image_uri`` is required. If also ``None``,
109+
then a ``ValueError`` will be raised.
106110
framework_version (str): Chainer version you want to use for
107111
executing your model training code. Defaults to ``None``. Required
108112
unless ``image_uri`` is provided.

src/sagemaker/huggingface/model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ def __init__(
133133
py_version (str): Python version you want to use for executing your
134134
model training code. Defaults to ``None``. Required unless
135135
``image_uri`` is provided.
136-
image_uri (str): A Docker image URI. Defaults to None. If not specified, a
136+
image_uri (str): A Docker image URI. Defaults to None. For serverless
137+
inferece, it is required. More image information can be found in
138+
`Amazon SageMaker provided algorithms and Deep Learning Containers
139+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
140+
For instance based inference, if not specified, a
137141
default image for PyTorch will be used. If ``framework_version``
138142
or ``py_version`` are ``None``, then ``image_uri`` is required. If
139143
also ``None``, then a ``ValueError`` will be raised.

src/sagemaker/mxnet/model.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ def __init__(
107107
py_version (str): Python version you want to use for executing your
108108
model training code. Defaults to ``None``. Required unless
109109
``image_uri`` is provided.
110-
image_uri (str): A Docker image URI (default: None). If not specified, a
111-
default image for MXNet will be used.
112-
110+
image_uri (str): A Docker image URI (default: None). For serverless
111+
inferece, it is required. More image information can be found in
112+
`Amazon SageMaker provided algorithms and Deep Learning Containers
113+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
114+
For instance based inference, if not specified, a default image for
115+
MXNet will be used.
113116
If ``framework_version`` or ``py_version`` are ``None``, then
114117
``image_uri`` is required. If also ``None``, then a ``ValueError``
115118
will be raised.

src/sagemaker/pytorch/model.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ def __init__(
107107
py_version (str): Python version you want to use for executing your
108108
model training code. Defaults to ``None``. Required unless
109109
``image_uri`` is provided.
110-
image_uri (str): A Docker image URI (default: None). If not specified, a
111-
default image for PyTorch will be used. If ``framework_version``
112-
or ``py_version`` are ``None``, then ``image_uri`` is required. If
113-
also ``None``, then a ``ValueError`` will be raised.
110+
image_uri (str): A Docker image URI (default: None). For serverless
111+
inferece, it is required. More image information can be found in
112+
`Amazon SageMaker provided algorithms and Deep Learning Containers
113+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
114+
For instance based inference, if not specified, a default image for
115+
PyTorch will be used. If ``framework_version`` or ``py_version`` are
116+
``None``, then ``image_uri`` is required. If also ``None``, then a
117+
``ValueError`` will be raised.
114118
predictor_cls (callable[str, sagemaker.session.Session]): A function
115119
to call to create a predictor with an endpoint name and
116120
SageMaker ``Session``. If specified, ``deploy()`` returns the

src/sagemaker/sklearn/model.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ def __init__(
102102
model training code (default: 'py3'). Currently, 'py3' is the only
103103
supported version. If ``None`` is passed in, ``image_uri`` must be
104104
provided.
105-
image_uri (str): A Docker image URI (default: None). If not specified, a
106-
default image for Scikit-learn will be used.
107-
105+
image_uri (str): A Docker image URI (default: None). For serverless
106+
inferece, it is required. More image information can be found in
107+
`Amazon SageMaker provided algorithms and Deep Learning Containers
108+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
109+
For instance based inference, if not specified, a default image for
110+
Scikit-learn will be used.
108111
If ``framework_version`` or ``py_version`` are ``None``, then
109112
``image_uri`` is required. If also ``None``, then a ``ValueError``
110113
will be raised.

src/sagemaker/tensorflow/model.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,14 @@ def __init__(
145145
file which should be executed as the entry point to model
146146
hosting. If ``source_dir`` is specified, then ``entry_point``
147147
must point to a file located at the root of ``source_dir``.
148-
image_uri (str): A Docker image URI (default: None). If not specified, a
149-
default image for TensorFlow Serving will be used. If
150-
``framework_version`` is ``None``, then ``image_uri`` is required.
151-
If also ``None``, then a ``ValueError`` will be raised.
148+
image_uri (str): A Docker image URI (default: None). For serverless
149+
inferece, it is required. More image information can be found in
150+
`Amazon SageMaker provided algorithms and Deep Learning Containers
151+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
152+
For instance based inference, if not specified, a default image for
153+
TensorFlow Serving will be used. If ``framework_version`` is ``None``,
154+
then ``image_uri`` is required. If also ``None``, then a ``ValueError``
155+
will be raised.
152156
framework_version (str): Optional. TensorFlow Serving version you
153157
want to use. Defaults to ``None``. Required unless ``image_uri`` is
154158
provided.

src/sagemaker/xgboost/model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ def __init__(
9191
entry_point (str): Path (absolute or relative) to the Python source file which should
9292
be executed as the entry point to model hosting. If ``source_dir`` is specified,
9393
then ``entry_point`` must point to a file located at the root of ``source_dir``.
94-
image_uri (str): A Docker image URI (default: None). If not specified, a default image
95-
for XGBoost is be used.
94+
image_uri (str): A Docker image URI (default: None). For serverless inferece, it is
95+
required. More image information can be found in
96+
`Amazon SageMaker provided algorithms and Deep Learning Containers
97+
<https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html>`_.
98+
For instance based inference, if not specified, a default image for XGBoost
99+
is be used.
96100
py_version (str): Python version you want to use for executing your model training code
97101
(default: 'py3').
98102
framework_version (str): XGBoost version you want to use for executing your model

0 commit comments

Comments
 (0)