Skip to content

Commit 597ced1

Browse files
authored
Add docs on TensorFlowModel class usage + requirements file for serving (#393)
* Add docs on TensorFlowModel class usage + requirements file for serving * PR updates
1 parent cb184cb commit 597ced1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/sagemaker/tensorflow/README.rst

+32
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,38 @@ When the ``deploy`` call finishes, the created SageMaker Endpoint is ready for p
647647
how to make predictions against the Endpoint, how to use different content-types in your requests, and how to extend the Web server
648648
functionality.
649649

650+
Deploying directly from model artifacts
651+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
652+
653+
If you already have existing model artifacts, you can skip training and deploy them directly to an endpoint:
654+
655+
.. code:: python
656+
657+
from sagemaker.tensorflow import TensorFlowModel
658+
659+
tf_model = TensorFlowModel(model_data='s3://mybucket/model.tar.gz',
660+
role='MySageMakerRole',
661+
entry_point='entry.py',
662+
name='model_name')
663+
664+
predictor = tf_model.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge')
665+
666+
You can also optionally specify a pip `requirements file <https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format>`_ if you need to install additional packages into the deployed
667+
runtime environment by including it in your source_dir and specifying it in the ``'SAGEMAKER_REQUIREMENTS'`` env variable:
668+
669+
.. code:: python
670+
671+
from sagemaker.tensorflow import TensorFlowModel
672+
673+
tf_model = TensorFlowModel(model_data='s3://mybucket/model.tar.gz',
674+
role='MySageMakerRole',
675+
entry_point='entry.py',
676+
source_dir='my_src', # directory which contains entry_point script and requirements file
677+
name='model_name',
678+
env={'SAGEMAKER_REQUIREMENTS': 'requirements.txt'}) # path relative to source_dir
679+
680+
predictor = tf_model.deploy(initial_instance_count=1, instance_type='ml.c4.xlarge')
681+
650682
651683
Making predictions against a SageMaker Endpoint
652684
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)