【问题标题】:Received client error (400) deploying huggingface bigscience/bloom to SageMaker收到客户端错误 (400) 将 huggingface bigscience/bloom 部署到 SageMaker
【发布时间】:2023-01-30 20:20:21
【问题描述】:

我想在 SageMaker 上部署 Bloom,这样我就有了一个可以使用的 Bloom 推理 API。我首先在 SageMaker jupyter notebook 中运行以下命令:

from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
    'HF_MODEL_ID':'bigscience/bloom',
    'HF_TASK':'text-generation'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
    transformers_version='4.17.0',
    pytorch_version='1.10.2',
    py_version='py38',
    env=hub,
    role=role, 
)

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
    initial_instance_count=1, # number of instances
    instance_type='ml.m5.xlarge' # ec2 instance type
)

predictor.predict({
    'inputs': "Can you please let us know more details about your "
})

产生了:

---------------------------------------------------------------------------
ModelError                                Traceback (most recent call last)
/tmp/ipykernel_15151/842216467.py in <cell line: 1>()
----> 1 predictor.predict({
      2         'inputs': "Can you please let us know more details about your "
      3 })

~/anaconda3/envs/python3/lib/python3.8/site-packages/sagemaker/predictor.py in predict(self, data, initial_args, target_model, target_variant, inference_id)
    159             data, initial_args, target_model, target_variant, inference_id
    160         )
--> 161         response = self.sagemaker_session.sagemaker_runtime_client.invoke_endpoint(**request_args)
    162         return self._handle_response(response)
    163 

~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    393                     "%s() only accepts keyword arguments." % py_operation_name)
    394             # The "self" in this scope is referring to the BaseClient.
--> 395             return self._make_api_call(operation_name, kwargs)
    396 
    397         _api_call.__name__ = str(py_operation_name)

~/anaconda3/envs/python3/lib/python3.8/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    723             error_code = parsed_response.get("Error", {}).get("Code")
    724             error_class = self.exceptions.from_code(error_code)
--> 725             raise error_class(parsed_response, operation_name)
    726         else:
    727             return parsed_response

ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{
  "code": 400,
  "type": "InternalServerException",
  "message": "\u0027bloom\u0027"
}
". See https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#logEventViewer:group=/aws/sagemaker/Endpoints/huggingface-pytorch-inference-2022-07-29-23-06-38-076 in account 162923941922 for more information.

cloudwatch 日志只显示:

2022-07-29T23:09:09,135 [INFO ] W-bigscience__bloom-4-stdout com.amazonaws.ml.mms.wlm.WorkerLifeCycle -     raise PredictionException(str(e), 400)

如何在不遇到此问题的情况下将其部署在 sagemaker 上?

【问题讨论】:

    标签: python-3.x amazon-sagemaker huggingface-transformers


    【解决方案1】:

    我看到您正在使用 this 示例。 4XX 错误通常发生在模型未下载且无法从 HuggingFace Hub 获得或未部署到 SageMaker 时。如果模型已部署并使用本地模式进行推理,我建议检查您的 SageMaker 控制台。

    【讨论】:

      【解决方案2】:

      我有相同的问题。请问有更新吗?如果没有,我会在解决后立即通知您。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-04-08
        • 2021-10-01
        • 2022-12-07
        • 2022-12-04
        • 2016-09-24
        • 2021-12-27
        • 1970-01-01
        • 2022-08-02
        相关资源
        最近更新 更多