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

将S3存储桶模型部署到SageMaker时遇InternalFailure错误排查

问题描述

在使用SageMaker Notebook从S3存储桶部署模型时出现错误,待部署模型为openchat-3.5-0106(已上传至S3)。
错误信息:

ClientError: An error occurred (InternalFailure) when calling the CreateModel operation (reached max retries: 4):

使用代码如下:

import json
import sagemaker
import boto3
from sagemaker.huggingface import HuggingFaceModel
from botocore.config import Config

sm_boto = boto3.client('sagemaker', 
                       config=Config(connect_timeout=5, read_timeout=60, retries={'max_attempts': 20}))
sagemaker_session = sagemaker.Session(sagemaker_client=sm_boto)
role = sagemaker.get_execution_role(sagemaker_session=sagemaker_session)

#! 已确认模型路径可用
model_path = "s3://arn:aws:s3:us-east-1:******:****/******"

huggingface_model = HuggingFaceModel(
    model_data = model_path,
    role=role,
    transformers_version="4.6", # 使用的transformers版本
    pytorch_version="1.7", # 使用的pytorch版本
    py_version='py36',
)

predictor = huggingface_model.deploy(
    initial_instance_count=1,
    instance_type="ml.m5.2xlarge",
)

已尝试延长超时时间和重试次数,但仍提示达到4次最大重试,需排查代码或环境问题。

排查步骤
  • 修正S3路径格式:你当前的model_path用了ARN格式,SageMaker要求的正确路径是s3://bucket-name/path/to/model.tar.gz,需改成标准S3桶文件路径。
  • 验证模型包完整性:模型必须打包成model.tar.gz压缩包,包内要包含pytorch_model.bin、config.json、分词器相关文件等,可下载解压确认无损坏。
  • 升级框架版本:你用的transformers 4.6和pytorch 1.7版本过旧,不兼容openchat-3.5-0106这类新模型,建议更换为兼容组合,比如:
    transformers_version="4.30.2",
    pytorch_version="2.0.1",
    py_version='py310',
    
  • 检查IAM角色权限:确保SageMaker执行角色拥有s3:GetObject(访问模型所在S3桶)、sagemaker:CreateModel等部署相关权限,必要时临时添加AmazonSageMakerFullAccess测试。
  • 查看详细日志:到SageMaker控制台找到对应任务,查看CloudWatch日志,里面会有内部错误的具体原因(比如模型解压失败、依赖缺失)。
  • 更换实例类型:ml.m5.2xlarge的16GB内存可能不足以加载openchat-3.5-0106,尝试换成ml.m5.4xlarge或带GPU的ml.g4dn.xlarge实例。

内容的提问来源于stack exchange,提问作者FAIZ AHMED

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 15:02:15