首页 > 解决方案 > 如何在 Vertex AI 中访问 AIP_STORAGE_URI?

问题描述

我上传了一个模型

gcloud beta ai models upload --artifact-uri

在我访问的 docker 中AIP_STORAGE_URI。我看到这AIP_STORAGE_URI是另一个 Google 存储位置,所以我尝试使用下载文件,storage.Client()但它说我无权访问:

google.api_core.exceptions.Forbidden: 403 GET https://storage.googleapis.com/storage/v1/b/caip-tenant-***-***-*-*-***?projection=noAcl&prettyPrint=false: custom-online-prediction@**.iam.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket

我正在使用默认服务帐户运行此端点。

https://cloud.google.com/vertex-ai/docs/predictions/custom-container-requirements#artifacts

根据上面的链接: The service account that your container uses by default has permission to read from this URI.

我究竟做错了什么?

标签: google-cloud-platformgoogle-cloud-vertex-ai

解决方案


错误背后的原因是,Vertex AI 使用的默认服务帐户具有“<a href="https://cloud.google.com/storage/docs/access-control/iam-roles#standard-roles" rel ="nofollow noreferrer">存储对象查看者”角色,排除storage.buckets.get权限。同时,该storage.Client()部分代码storage.buckets.get向默认服务账户无权访问的 Vertex AI 托管存储桶发出请求。

要解决此问题,我建议您按照以下步骤操作 -

  • 更改自定义代码以使用项目中的模型工件访问存储桶,而不是使用AIP_STORAGE_URI指向 Vertex AI 托管存储桶中模型位置的环境变量。

  • 创建您自己的服务帐户并授予该服务帐户自定义代码所需的所有权限。对于此特定错误,具有storage.buckets.get权限的角色,例如。存储管理员(“roles/storage.admin”)必须授予服务帐户。

  • 部署模型时,在“服务帐户”字段中提供新创建的服务帐户。


推荐阅读