搭配 Agent Platform Workbench 執行個體使用預留項目

本文說明如何使用 Compute Engine 預留資源,確保 Gemini Enterprise Agent Platform Workbench 執行個體有足夠的虛擬機器 (VM) 資源可供執行。

預訂是 Compute Engine 的功能。預留項目有助於確保擁有可用的資源,隨時都能建立具有相同硬體 (記憶體和 vCPU) 和選用資源 (GPU 和本機 SSD 磁碟) 的 VM。

建立預留項目時,Compute Engine 會驗證指定可用區是否提供要求的容量。如果提供,Compute Engine 就會預留資源、建立預留項目,並發生下列情況:

  • 您可立即使用預留資源,且預留資源會一直可用,直到您刪除預留項目為止。

  • 系統會根據與執行中 VM 相同的隨選費率,向您收取預留資源的費用 (包括任何適用折扣),直到您刪除預留項目為止。使用預留項目時,VM 不會產生重複的資源費用,因為預留資源的費用已計入預留項目。詳情請參閱「Compute Engine 可用區資源的預留項目」。

限制與需求

當 Agent Platform Workbench 執行個體使用預留項目時,Compute Engine 預留項目的所有限制都適用。請參閱「預留的運作方式」。

此外,將預留項目與 Agent Platform Workbench 執行個體搭配使用時,須遵守下列限制和規定:

  • 預訂必須符合下列其中一項條件:

    • 與 Agent Platform Workbench 執行個體位於相同專案。
    • 與 Agent Platform Workbench 執行個體共用同一個專案。
  • 如要使用預留項目,預留項目的 VM 屬性必須與 Agent Platform Workbench 執行個體完全相符。舉例來說,如果預留項目指定 e2-standard-8 機型,則 Agent Platform Workbench 執行個體也必須使用 e2-standard-8 機型,才能使用預留項目。請參閱需求條件

事前準備

  1. 請詳閱預訂 規定 限制
  2. 請參閱共用預訂的配額規定 限制
  3. 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
  4. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  5. Enable the Compute Engine and Notebooks APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. Enable the Compute Engine and Notebooks APIs.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

必要的角色

如要取得搭配 Agent Platform Workbench 執行個體使用預留資源所需的權限,請要求管理員在專案中授予您下列 IAM 角色:

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

建立預留項目

建立 Compute Engine 預留項目。可以是單一專案預留項目或共用預留項目。預留項目可以是隨選或未來預留項目。詳情請參閱「選擇預留項目類型」。

在新執行個體中使用預留項目

如要建立使用預留資源的 Agent Platform Workbench 執行個體,請使用 Google Cloud 控制台或 REST API。

控制台

如要建立使用預留項目的 Agent Platform Workbench 執行個體,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的「Instances」(執行個體) 頁面。

    前往「Instances」(執行個體)

  2. 按一下 「建立新標籤」

  3. 在「New instance」對話方塊中,按一下「Advanced options」

  4. 在「建立執行個體」對話方塊的「機型」部分中,選取符合預留項目的機型和 GPU 設定。

  5. 在「CPU Platform and GPU」(CPU 平台和 GPU) 下的「Reservations」(保留項目) 選單中,選取要使用的保留項目。

  6. 點選「建立」

    Agent Platform Workbench 會建立執行個體,並自動啟動。執行個體可供使用時,Agent Platform Workbench 會啟用「Open JupyterLab」(開啟 JupyterLab) 連結。

REST

使用任何要求資料之前,請先修改下列項目的值:

  • PROJECT_ID:專案 ID
  • LOCATION:執行個體所在的可用區
  • INSTANCE_NAME:執行個體的名稱
  • MACHINE_TYPE:執行個體的機型
  • RESERVATION_TYPE:預訂類型,必須為 RESERVATION_ANYRESERVATION_SPECIFIC
  • RESERVATION_NAME:使用 RESERVATION_SPECIFIC 類型時的預訂名稱
    • 如要預留同一個專案中的資源,可以使用預留 ID。
    • 如要使用其他專案中的預留項目,請務必使用完整預留項目路徑,例如:projects/PROJECT_ID/reservations/RESERVATION_NAME

HTTP 方法和網址:

POST https://notebooks.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/instances?instanceId=INSTANCE_NAME

JSON 要求內文:

{
  "gce_setup": {
    "machine_type": "MACHINE_TYPE",
    "reservation_affinity": {
      "consume_reservation_type": "RESERVATION_TYPE",
      "key": "compute.googleapis.com/reservation-name",
      "values": ["RESERVATION_NAME"]
    }
  }
}

如要傳送要求,請選擇以下其中一個選項:

curl

將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://notebooks.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/instances?instanceId=INSTANCE_NAME"

PowerShell

將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://notebooks.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/instances?instanceId=INSTANCE_NAME" | Select-Object -Expand Content
如果成功,回應主體會包含 Operation 的執行個體。

詳情請參閱 projects.locations.instances.create REST API 說明文件

停止使用預留項目

如要停止使用預留項目,可以刪除預留項目

如要繼續將預留項目用於其他資源,但不想讓現有的 Agent Platform Workbench 執行個體使用,請務必刪除該執行個體。

帳單

使用 Compute Engine 預留項目時,系統會針對下列項目向您收費:

  • Compute Engine 資源,包括任何適用的承諾使用折扣 (CUD),均以 Compute Engine 定價計費。這類費用在 SKU 上會標示 goog-vertex-ai-product: workbench-instances。請參閱 Compute Engine 定價

  • 除了基礎架構使用費,您還必須支付 Agent Platform Workbench 管理費。請參閱 Agent Platform Workbench 定價

疑難排解

如要瞭解如何診斷及解決使用 Agent Platform Workbench 執行個體預訂項目時發生的錯誤,請參閱「排解 Agent Platform Workbench 執行個體問題」。

後續步驟