You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何替换部署在SageMaker上的MLflow模型?

解决SageMaker上MLflow模型更新的问题

方法一:使用update_deployment方法替换模型

直接调用MLflow部署客户端的update_deployment方法,传入端点名称和新的模型URI、配置即可:

client.update_deployment(
    name=ENDPOINT_NAME,
    model_uri=f"models:/{REGISTERED_MODEL_NAME}/latest",
    config={
        "region_name": AWS_REGION,
        "execution_role_arn": SAGEMAKER_ROLE_ARN,
        "instance_type": INSTANCE_TYPE,
        "instance_count": INSTANCE_COUNT,
        "synchronous": True,
        "timeout_seconds": 1800,
    }
)

该方法对应错误提示中的replace模式,会直接替换现有端点的模型与配置。

方法二:在create_deployment的config中指定部署模式

若坚持使用create_deployment方法,可在config字典内添加mode参数并设置为"replace":

client.create_deployment(
    name=ENDPOINT_NAME,
    model_uri=f"models:/{REGISTERED_MODEL_NAME}/latest",
    flavor="python_function",
    config={
        "region_name": AWS_REGION,
        "execution_role_arn": SAGEMAKER_ROLE_ARN,
        "instance_type": INSTANCE_TYPE,
        "instance_count": INSTANCE_COUNT,
        "synchronous": True,
        "timeout_seconds": 1800,
        "mode": "replace"  # 指定替换模式
    }
)

虽然create_deployment方法本身没有显式的mode参数,但SageMaker部署的config支持传递该参数,以此覆盖默认的create模式。

补充说明

  • replace模式:完全替换现有端点的模型与配置,适合全量更新模型的场景;
  • add模式:向现有端点添加新的模型变体,适用于A/B测试等多模型并行运行的场景,此时需在config中额外指定variant_name参数区分不同变体。

内容的提问来源于stack exchange,提问作者David A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 23:42:17