【问题标题】:Google Cloud Vertex AI - 400 'dedicated_resources' is not supported for ModelGoogle Cloud Vertex AI - 模型不支持 400 'dedicated_resources'
【发布时间】:2021-12-03 05:14:45
【问题描述】:

我正在尝试使用 Python SDK 在 Google Cloud Platform 上部署我使用 Vertex AI 训练的文本分类模型。

from google.cloud import aiplatform

import os

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "<key location>"

def create_endpoint(
    project_id: str,
    display_name: str,
    location: str,
    sync: bool = True,
):
    endpoint = aiplatform.Endpoint.create(
        display_name=display_name, project=project_id, location=location,
    )

    print(endpoint.display_name)
    print(endpoint.resource_name)
    return endpoint

def deploy_model(project_id, location, model_id):
    model_location = "projects/{}/locations/{}/models/{}".format(project_id, location, model_id)

    print("Initializing Vertex AI")
    aiplatform.init(project=project_id, location=location)

    print("Getting model from {}".format(model_location))
    model = aiplatform.Model(model_location)

    print("Creating endpoint.")
    endpoint = create_endpoint(project_id, "{}_endpoint".format(model_id), location)

    print("Deploying endpoint")
    endpoint.deploy(
        model,
        machine_type="n1-standard-4",
        min_replica_count=1,
        max_replica_count=5,
        accelerator_type='NVIDIA_TESLA_K80',
        accelerator_count=1
    )

    return endpoint

endpoint = deploy_model(
    "<project name>",
    "us-central1",
    "<model id>",
)

不幸的是,当我运行此代码时,在触发 endpoint.deploy 后收到此错误: google.api_core.exceptions.InvalidArgument: 400 'dedicated_resources' is not supported for Model... 后跟模型位置。

注意我用 交换了我的值以隐藏我的本地工作区变量的地方。

【问题讨论】:

  • 哪个语句抛出错误?
  • 部署声明

标签: python google-cloud-platform google-cloud-vertex-ai


【解决方案1】:

您遇到错误,因为无法将自定义机器分配给文本分类模型。根据documentation,只有自定义模型和 AutoML 表格模型可以使用自定义机器。对于表格模型以外的 AutoML 模型,Vertex AI 会自动配置机器类型。

如果您想使用自定义训练模型或 AutoML 表格模型 要提供在线预测,您必须在使用时指定机器类型 将模型资源作为 DeployedModel 部署到端点。 其他 AutoML 模型类型,Vertex AI 配置机器类型 自动。

解决方法是删除endpoint.deploy() 上的机器相关参数,您应该能够部署模型。

print("Deploying endpoint")
endpoint.deploy(model)

【讨论】:

  • 我今天早上重新阅读了文档,发现所有其他参数都是可选的。我尝试不使用这些值,但它解除了阻塞。感谢您分享文档的链接。它的版本和教程太多了,有时感觉就像你不得不意外遇到这样的重要细节。
猜你喜欢
  • 2022-11-11
  • 1970-01-01
  • 2023-02-05
  • 2021-12-28
  • 2021-08-28
  • 2020-10-27
  • 1970-01-01
  • 2022-11-15
  • 2022-08-05
相关资源
最近更新 更多