設定專案和開發環境

為協助您開始使用 Vertex AI,本頁面將逐步說明如何建立 Google Cloud 專案及啟用 Vertex AI API。如果您沒有執行這些工作的權限,請要求管理員為您設定專案並啟用 Vertex AI。本頁也說明如何在本地開發環境中設定 Google Cloud CLI。

設定專案

請按照下列步驟設定專案:

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Vertex AI API.

    Enable the API

  8. 設定驗證方法

      Select the tabs for how you plan to access the API:

      Console

      When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

      gcloud

      1. Install the Google Cloud CLI.

      2. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

      3. To initialize the gcloud CLI, run the following command:

        gcloud init
      4. After initializing the gcloud CLI, update it and install the required components:

        gcloud components update
        gcloud components install beta
      5. 如要設定 gcloud CLI,讓它使用服務帳戶模擬功能向 Google API 進行驗證,而不是使用您的使用者憑證,請執行下列指令:

        gcloud config set auth/impersonate_service_account SERVICE_ACCT_EMAIL

        詳情請參閱「服務帳戶模擬」。

        用戶端程式庫

        如要在本機開發環境中使用用戶端程式庫,請安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。

        1. Install the Google Cloud CLI.

        2. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

        3. To initialize the gcloud CLI, run the following command:

          gcloud init
        4. After initializing the gcloud CLI, update it and install the required components:

          gcloud components update
          gcloud components install beta
        5. If you're using a local shell, then create local authentication credentials for your user account:

          gcloud auth application-default login

          You don't need to do this if you're using Cloud Shell.

          If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

        詳情請參閱 Google Cloud 驗證說明文件中的「 為本機開發環境設定 ADC」。

        如要設定本機 ADC 檔案,使用服務帳戶模擬功能向 Google API 進行驗證,而非使用您的使用者憑證,請執行下列指令:

        gcloud auth application-default login --impersonate-service-account=SERVICE_ACCT_EMAIL

        詳情請參閱「服務帳戶模擬」。

        REST

        如要在本機開發環境中使用 REST API,請使用您提供給 gcloud CLI 的憑證。

        1. Install the Google Cloud CLI.

        2. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

        3. To initialize the gcloud CLI, run the following command:

          gcloud init
        4. After initializing the gcloud CLI, update it and install the required components:

          gcloud components update
          gcloud components install beta

        詳情請參閱 Google Cloud 驗證說明文件中的「Authenticate for using REST」。

        您可以使用服務帳戶模擬功能,為 REST API 要求產生存取權杖。 詳情請參閱「模擬服務帳戶」。

        如要瞭解如何為正式版環境設定驗證,請參閱 Google Cloud 驗證說明文件中的 Set up Application Default Credentials for code running on Google Cloud

        請管理員為您設定 Vertex AI 專案

        本節說明管理員如何授予使用 Vertex AI 所需的角色。

        1. 決定有意義的專案名稱和專案 ID,以識別專案。 如果您是機構成員或打算建立多個專案,請考慮要遵循或可遵循哪些命名慣例和資料夾階層,讓專案組織結構一目瞭然。
        2. 必要角色:
          1. 大多數 Vertex AI 功能的存取權都是透過 Vertex AI 使用者 (roles/aiplatform.user) IAM 角色授予,對於大多數 Vertex AI 使用者來說應該足夠。如要全面控管 Vertex AI 資源,可以要求 Vertex AI 管理員 (roles/aiplatform.admin)角色。如要瞭解這些角色與其他 Vertex AI 角色的差異,請參閱「運用 IAM 執行 Vertex AI 存取控管」。
          2. 如果您也打算在 Google Cloud中使用 Vertex AI Workbench 執行個體,請要求管理員授予您專案的「Notebooks 管理員」(roles/notebooks.admin) IAM 角色,以及專案或 Compute Engine 預設服務帳戶的「服務帳戶使用者」(roles/iam.serviceAccountUser) IAM 角色。
          3. 此外,如要啟用必要的 API,您必須具備服務使用管理員 (roles/serviceusage.serviceUsageAdmin) IAM 角色,或是請管理員按照前幾個步驟為您啟用 API。
        3. 請管理員為您啟用 Vertex AI API。 如果您具備「服務用量管理員」(roles/serviceusage.serviceUsageAdmin) IAM 角色,就能自行完成這項操作。

        後續步驟