為協助您開始使用 Vertex AI,本頁面將逐步說明如何建立 Google Cloud 專案及啟用 Vertex AI API。如果您沒有執行這些工作的權限,請要求管理員為您設定專案並啟用 Vertex AI。本頁面也說明如何在本地開發環境中設定 Google Cloud CLI。
設定專案
請按照下列步驟設定專案:
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.
設定驗證方法
-
安裝 Google Cloud CLI。
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
執行下列指令,初始化 gcloud CLI:
gcloud init -
初始化 gcloud CLI 後,請更新 gcloud CLI 並安裝必要元件:
gcloud components update gcloud components install beta
-
安裝 Google Cloud CLI。
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
初始化 gcloud CLI 後,請更新 gcloud CLI 並安裝必要元件:
gcloud components update gcloud components install beta
-
如果您使用本機殼層,請為使用者帳戶建立本機驗證憑證:
gcloud auth application-default login
如果您使用 Cloud Shell,則不需要執行這項操作。
如果系統傳回驗證錯誤,且您使用外部識別資訊提供者 (IdP),請確認您已 使用聯合身分登入 gcloud CLI。
-
安裝 Google Cloud CLI。
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
初始化 gcloud CLI 後,請更新 gcloud CLI 並安裝必要元件:
gcloud components update gcloud components install beta
選取您打算存取 API 的方式所對應的分頁:
控制台
使用 Google Cloud 控制台存取 Google Cloud 服務和 API 時,無須設定驗證。
gcloud
如要設定 gcloud CLI,使用服務帳戶模擬功能向 Google API 進行驗證,而非使用使用者憑證,請執行下列指令:
gcloud config set auth/impersonate_service_account SERVICE_ACCT_EMAIL
詳情請參閱「服務帳戶模擬」。
用戶端程式庫
如要在本機開發環境中使用用戶端程式庫,請安裝並初始化 gcloud CLI,然後使用使用者憑證設定應用程式預設憑證。
詳情請參閱 Google Cloud 驗證說明文件中的「 為本機開發環境設定 ADC」。
如要設定本機 ADC 檔案,使用服務帳戶模擬功能向 Google API 進行驗證,而非使用使用者憑證,請執行下列指令:
gcloud auth application-default login --impersonate-service-account=SERVICE_ACCT_EMAIL
詳情請參閱「服務帳戶模擬」。
REST
如要在本機開發環境中使用 REST API,請使用您提供給 gcloud CLI 的憑證。
詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」。
您可以使用服務帳戶模擬功能,為 REST API 要求產生存取權杖。 詳情請參閱「模擬服務帳戶」。
如要瞭解如何設定正式環境的驗證機制,請參閱 Google Cloud 驗證說明文件中的「 為在 Google Cloud上執行的程式碼設定應用程式預設憑證 」。
請管理員為您設定 Vertex AI 專案
本節說明管理員如何授予使用 Vertex AI 時所需的角色。
- 決定有意義的專案名稱和專案 ID,以識別專案。 如果您是機構成員或打算建立多個專案,請考慮要遵循或可遵循哪些命名慣例和資料夾階層,讓專案整理作業更清楚明瞭。
- 必要角色:
- 「Vertex AI 使用者」
(roles/aiplatform.user)IAM 角色可授予大部分 Vertex AI 功能的存取權,應足以滿足大多數 Vertex AI 使用者的需求。如要全面控管 Vertex AI 資源,可以要求 Vertex AI 管理員(roles/aiplatform.admin)角色。如要瞭解這些角色與其他 Vertex AI 角色的差異,請參閱「運用 IAM 執行 Vertex AI 存取控管」。 - 如果您也打算在 Google Cloud中使用 Vertex AI Workbench 執行個體,請要求管理員授予您專案的 Notebooks Administrator
(roles/notebooks.admin)IAM 角色,以及專案或 Compute Engine 預設服務帳戶的 Service Account User(roles/iam.serviceAccountUser)IAM 角色。 - 此外,如要啟用必要的 API,您必須具備服務使用管理員
(roles/serviceusage.serviceUsageAdmin)IAM 角色,或是請管理員按照前幾個步驟為您啟用 API。
- 「Vertex AI 使用者」
- 請管理員為您啟用 Vertex AI API。
如果您具備「服務用量管理員」
(roles/serviceusage.serviceUsageAdmin)IAM 角色,就能自行完成這項操作。
後續步驟
閱讀 Vertex AI 總覽。
逐步完成其中一個 Vertex AI 使用教學課程。
瞭解如何使用 Python 適用的 Vertex AI SDK,以其他方式與 Vertex AI 互動。