为什么我收到此错误“google.api_core.exceptions.ResourceExhausted:429 收到的尾随元数据大小超出限制”?

问题描述

我是谷歌云平台的新手。在 google Vertex AI 上上传模型后,我创建了一个端点。但是当我运行示例请求中建议的预测函数 (python) 时,我收到此错误:-

Traceback (most recent call last):
  File "C:\Users\My\anaconda3\lib\site-packages\google\api_core\grpc_helpers.py",line 67,in 
error_remapped_callable
return callable_(*args,**kwargs)
File "C:\Users\My\anaconda3\lib\site-packages\grpc\_channel.py",line 923,in __call__
return _end_unary_response_blocking(state,call,False,None)
File "C:\Users\My\anaconda3\lib\site-packages\grpc\_channel.py",line 826,in 
_end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.RESOURCE_EXHAUSTED
    details = "received trailing Metadata size exceeds limit"
    debug_error_string = "{"created":"@1622724354.768000000","description":"Error received 
from peer ipv4:***.***.***.**","file":"src/core/lib/surface/call.cc","file_line":1063,"grpc_message":"received trailing Metadata size exceeds limit","grpc_status":8}">

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "b.py",line 39,in <module>
    predict_custom_trained_model_sample(
  File "b.py",line 28,in predict_custom_trained_model_sample
    response = client.predict(
  File "C:\Users\My\anaconda3\lib\site- 
   packages\google\cloud\aiplatform_v1\services\prediction_service\client.py",line 445,in 
predict
    response = rpc(request,retry=retry,timeout=timeout,Metadata=Metadata,)
  File "C:\Users\My\anaconda3\lib\site-packages\google\api_core\gapic_v1\method.py",line 145,in __call__
    return wrapped_func(*args,**kwargs)
  File "C:\Users\My\anaconda3\lib\site-packages\google\api_core\grpc_helpers.py",line 69,in 
error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc),exc)
  File "<string>",line 3,in raise_from
google.api_core.exceptions.ResourceExhausted: 429 received trailing Metadata size exceeds limit

我为预测而执行的代码

from typing import Dict
from google.cloud import aiplatform
from google.protobuf import json_format
from google.protobuf.struct_pb2 import Value


def predict_custom_trained_model_sample(
    project: str,endpoint_id: str,instance_dict: Dict,location: str = "us-central1",api_endpoint: str = "us-central1-aiplatform.googleapis.com",):
    # The AI Platform services require regional API endpoints.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once,and can be reused for 
multiple requests.
    client = 
aiplatform.gapic.PredictionServiceClient(client_options=client_options)
    # The format of each instance should conform to the deployed model's prediction input schema.
    instance = json_format.ParseDict(instance_dict,Value())
    instances = [instance]
    parameters_dict = {}
    parameters = json_format.ParseDict(parameters_dict,Value())
    endpoint = client.endpoint_path(
        project=project,location=location,endpoint=endpoint_id
    )
    response = client.predict(
        endpoint=endpoint,instances=instances,parameters=parameters
    )
    print("response")
    print(" deployed_model_id:",response.deployed_model_id)
    # The predictions are a google.protobuf.Value representation of the model's predictions.
    predictions = response.predictions
    for prediction in predictions:
        print(" prediction:",dict(prediction)) 

运行此代码后,我收到错误消息。 如果有人知道这个问题,请帮忙。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)