gpt4 book ai didi

amazon-web-services - 如何将 ML 模型从 ECS 部署到 Sagemaker?

转载 作者:行者123 更新时间:2023-11-30 09:18:37 25 4
gpt4 key购买 nike

我有一个在本地训练的模型,然后转移到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 上。我该如何克服这个问题?

最佳答案

您可以创建an instance of 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

关于amazon-web-services - 如何将 ML 模型从 ECS 部署到 Sagemaker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48537811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com