簡體   English   中英

如何將ML模型從ECS部署到Sagemaker?

[英]How can I deploy an ML model from ECS to Sagemaker?

我有一個在本地培訓的模型,然后轉移到了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。 我該如何克服這個問題?

您可以創建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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM