使用新端点配置更新 Sagemaker 端点

Updating Sagemaker Endpoint with new Endpoint Configuration

与 Sagemaker 重新训练模型的自动化有点混淆。

目前我有一个带有 Sagemaker LinearLerner 模型的笔记本实例正在执行 classification 任务。因此,我使用 Estimator 进行训练,然后部署创建 Endpoint 的模型。然后使用 Lambda 函数调用此端点,我将其添加到 API Gateway 接收 api 端点,可用于 POST 请求并使用 [=28 发回响应=].

现在我面临着再培训的问题。为此,我使用 serverless 方法和 lambda 函数获取 training_jobs 的环境变量。但是 Sagemaker 不允许重写训练作业的问题,你只能创建一个新的。我的目标是在新的培训工作和新的端点配置将应用于现有端点时自动化该部分,我不需要在 API 网关中更改任何内容。是否有可能以某种方式自动将新端点配置附加到现有端点?

谢谢

如果我对问题的理解正确,你应该可以使用 CreateEndpointConfig near the end of the training job, then use UpdateEndpoint:

Deploys the new EndpointConfig specified in the request, switches to using newly created endpoint, and then deletes resources provisioned for the endpoint using the previous EndpointConfig (there is no availability loss).

如果 API 网关/Lambda 是通过端点 ARN 路由的,则在使用 UpdateEndpoint 后不应更改。

是,使用 UpdateEndpoint 端点。但是,如果您使用的是 Python Sagemaker SDK,请注意,可能会有一些文档要求您调用

model.deploy(..., update_endpoint=True)

这显然在 Sagemaker SDK v2 中已弃用:

您应该改用 Predictor class to perform this update:

from sagemaker.predictor import Predictor
predictor = Predictor(endpoint_name="YOUR-ENDPOINT-NAME", sagemaker_session=sagemaker_session_object)
predictor.update_endpoint(instance_type="ml.t2.large", initial_instance_count=1)