Skip to content

Commit b943baa

Browse files
authored
Add an example for local mode deployment of models (#304)
If there is an existing model it can be deployed locally using local mode. This feature is already present but there was no example in the README.
1 parent 2fa160c commit b943baa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,30 @@ instance type.
192192
mxnet_estimator.delete_endpoint()
193193
194194
195+
If you have an existing model and would like to deploy it locally you can do that as well. If you don't
196+
specify a sagemaker_session argument to the MXNetModel constructor, the right session will be generated
197+
when calling model.deploy()
198+
199+
Here is an end to end example:
200+
201+
.. code:: python
202+
203+
import numpy
204+
from sagemaker.mxnet import MXNetModel
205+
206+
model_location = 's3://mybucket/my_model.tar.gz'
207+
code_location = 's3://mybucket/sourcedir.tar.gz'
208+
s3_model = MXNetModel(model_data=model_location, role='SageMakerRole',
209+
entry_point='mnist.py', source_dir=code_location)
210+
211+
predictor = s3_model.deploy(initial_instance_count=1, instance_type='local')
212+
data = numpy.zeros(shape=(1, 1, 28, 28))
213+
predictor.predict(data)
214+
215+
# Tear down the endpoint container
216+
predictor.delete_endpoint()
217+
218+
195219
For detailed examples of running docker in local mode, see:
196220

197221
- `TensorFlow local mode example notebook <https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/tensorflow_distributed_mnist/tensorflow_local_mode_mnist.ipynb>`__.

0 commit comments

Comments
 (0)