Last active
September 25, 2020 18:17
-
-
Save edumunozsala/14355e3b9c206bdd553989b3b767778c to your computer and use it in GitHub Desktop.
Deploy the model on Sagemaker CLTG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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