Skip to content

Instantly share code, notes, and snippets.

@edumunozsala
Last active September 25, 2020 18:17
Show Gist options
  • Save edumunozsala/14355e3b9c206bdd553989b3b767778c to your computer and use it in GitHub Desktop.
Save edumunozsala/14355e3b9c206bdd553989b3b767778c to your computer and use it in GitHub Desktop.
Deploy the model on Sagemaker CLTG
from sagemaker.predictor import RealTimePredictor
from sagemaker.pytorch import PyTorchModel
class StringPredictor(RealTimePredictor):
def __init__(self, endpoint_name, sagemaker_session):
super(StringPredictor, self).__init__(endpoint_name, sagemaker_session, content_type='text/plain')
# Create a model in Sagemaker
model = PyTorchModel(model_data=estimator.model_data,
role = role,
framework_version='0.4.0',
entry_point='predict.py',
source_dir='serve',
predictor_cls=StringPredictor)
# Deploy the model on a compute instance
predictor = model.deploy(initial_instance_count=1, instance_type='ml.m4.xlarge')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment