是否可以从另一个 GCP 项目请求 Vertex AI 端点?

Is it possible to request a Vertex AI endpoint from another GCP project?

我在 GCP Vertex AI 上训练了一个模型,并将其部署在端点上。

我可以使用此 python 代码 https://cloud.google.com/vertex-ai/docs/predictions/online-predictions-automl#aiplatform_predict_image_classification_sample-python

执行从样本到我的模型的预测

它适用于我的 GCP 项目。

我的问题是,是否可以从另一个 GCP 项目请求此端点?如果我在两个项目中设置服务帐户并设置 IAM 角色?

是的,这是可能的。例如,假设项目 A 托管模型,您有项目 A 和项目 B。

  • 在项目A中添加项目B的服务账号,并提供至少roles/aiplatform.user个预定义角色。请参阅 predefined roles 并查找 roles/aiplatform.user 以查看其中包含的完整角色。

  • 这个角色包含aiplatform.endpoints.*和aiplatform.batchPredictionJobs.*作为这些是 运行 预测所需的角色。

    See IAM permissions for Vertex AI

    Resource Operation Permissions needed
    batchPredictionJobs Create a batchPredictionJob aiplatform.batchPredictionJobs.create (permission needed on the parent resource)
    endpoints Predict an endpoint aiplatform.endpoints.predict (permission needed on the endpoint resource)

通过此设置,项目 B 将能够使用项目 A 中的模型进行 运行 预测。

注意:只需确保项目 B 的脚本指向项目 A 中的资源,如 project_idendpoint_id