`Model.deploy()` AutoML 失败,`400 'automatic_resources' 不支持模型`
`Model.deploy()` failing for AutoML with `400 'automatic_resources' is not supported for Model`
尝试使用 python SDK 部署 AutoML 模型,但收到错误
google.api_core.exceptions.InvalidArgument: 400 'automatic_resources' is not supported for Model
这就是我 运行:
from google.cloud import aiplatform
aiplatform.init(project="MY_PROJECT")
# model is an AutoML tabular model
model = aiplatform.Model("MY_MODEL_ID")
# this fails
model.deploy()
您遇到 automatic_resources
是因为为 AutoML Tables 部署模型需要用户在模型部署时定义机器类型。有关详细信息,请参阅 configure compute resources for prediction docs。
If you want to use a custom-trained model or an AutoML tabular model
to serve online predictions, you must specify a machine type when you
deploy the Model resource as a DeployedModel to an Endpoint.
您应该在代码中添加资源定义,以便继续部署。添加 machine_type
参数就足够了。有关完整列表,请参阅 supported machine types docs。
查看下面的代码:
from google.cloud import aiplatform
project = "your-project-id"
location = "us-central1"
model_id = "99999999"
aiplatform.init(project=project, location=location)
model_name = (f"projects/{project}/locations/{location}/models/{model_id}")
model = aiplatform.Model(model_name=model_name)
model.deploy(machine_type="n1-standard-4")
model.wait()
print(model.display_name)
输出:
尝试使用 python SDK 部署 AutoML 模型,但收到错误
google.api_core.exceptions.InvalidArgument: 400 'automatic_resources' is not supported for Model
这就是我 运行:
from google.cloud import aiplatform
aiplatform.init(project="MY_PROJECT")
# model is an AutoML tabular model
model = aiplatform.Model("MY_MODEL_ID")
# this fails
model.deploy()
您遇到 automatic_resources
是因为为 AutoML Tables 部署模型需要用户在模型部署时定义机器类型。有关详细信息,请参阅 configure compute resources for prediction docs。
If you want to use a custom-trained model or an AutoML tabular model to serve online predictions, you must specify a machine type when you deploy the Model resource as a DeployedModel to an Endpoint.
您应该在代码中添加资源定义,以便继续部署。添加 machine_type
参数就足够了。有关完整列表,请参阅 supported machine types docs。
查看下面的代码:
from google.cloud import aiplatform
project = "your-project-id"
location = "us-central1"
model_id = "99999999"
aiplatform.init(project=project, location=location)
model_name = (f"projects/{project}/locations/{location}/models/{model_id}")
model = aiplatform.Model(model_name=model_name)
model.deploy(machine_type="n1-standard-4")
model.wait()
print(model.display_name)
输出: