搭配使用預留項目和 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, if any are not already enabled.

    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, if any are not already enabled.

    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. 在「Create instance」(建立執行個體) 對話方塊的「Machine type」(機器類型) 區段中,選取與預留項目相符的機器類型和 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_ANY 或 RESERVATION_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 執行個體問題」。

後續步驟