1

我有一个在本地训练的模型,然后转移到 AWS ECS。我想将它部署到 Sagemaker。

目前,我这样做:

from sagemaker.estimator import Estimator
model = Estimator(image,
                  role, 1, 'ml.c4.2xlarge',
                  output_path="s3://{}/output".format(sess.default_bucket()),
                  sagemaker_session=sess)

但是当我打电话

from sagemaker.predictor import csv_serializer
predictor = agent.deploy(1, 'ml.t2.medium', serializer=csv_serializer)

我得到:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-0ca9477e4acb> in <module>()
      1 from sagemaker.predictor import csv_serializer
----> 2 predictor = model.deploy(1, 'ml.t2.medium', serializer=csv_serializer)

~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/estimator.py in deploy(self, initial_instance_count, instance_type, endpoint_name, **kwargs)
    177         """
    178         if not self.latest_training_job:
--> 179             raise RuntimeError('Estimator has not been fit yet.')
    180         endpoint_name = endpoint_name or self.latest_training_job.name
    181         self.deploy_instance_type = instance_type

RuntimeError: Estimator has not been fit yet.

但它已经适合了……只是不适用于 Sagemaker。我该如何克服这个问题?

4

1 回答 1

0

您可以创建一个实例Model以将模型部署到未在 SageMaker 中训练的端点:

mxnet_model = MXNetModel(model_data="s3://bucket/model.tar.gz", 
                         role="SageMakerRole", 
                         entry_point="trasform_script.py")

predictor = mxnet_model.deploy(instance_type="ml.c4.xlarge", 
                               initial_instance_count=1)

GitHub 存储库https://github.com/awslabs/amazon-sagemaker-examples包含有关如何部署模型的更多示例:https ://github.com/awslabs/amazon-sagemaker-examples/blob/master/advanced_functionality/tensorflow_iris_byom /tensorflow_BYOM_iris.ipynbhttps://github.com/awslabs/amazon-sagemaker-examples/tree/master/advanced_functionality/mxnet_mnist_byom

于 2018-04-09T04:05:17.893 回答