管理 TPU Spot VM

Spot VM 以極低折扣率提供未使用的容量。Spot VM 隨時會被搶佔 (關閉),但與先占 TPU 不同,Spot VM 的執行時間長度沒有限制。您無法重新啟動 TPU Spot VM,必須在先佔後重新建立。如要進一步瞭解 Spot VM,請參閱 Compute Engine 的 Spot VM 說明文件

建立 TPU Spot VM

您可以使用排序資源建立 TPU Spot VM,這會將建立要求加入佇列,並在可用時提供容量。最佳做法是將 TPU 建立為佇列資源。詳情請參閱「佇列資源使用者指南」。

以下範例說明如何使用排隊資源建立 TPU Spot VM:

gcloud

--spot 旗標新增至 gcloud compute tpus queued-resources 指令:

gcloud compute tpus queued-resources create QUEUED_RESOURCE_ID \
    --node-id=NODE_ID \
    --zone=europe-west4-a \
    --accelerator-type=v3-8 \
    --runtime-version=tpu-vm-tf-2.17.1-pod-pjrt \
    --spot

curl

spot: {} 新增至要求主體:

curl -X POST https://tpu.googleapis.com/v2alpha1/projects/PROJECT_ID/locations/europe-west4-a/queuedResources?queued_resource_id=QUEUED_RESOURCE_ID \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -d '{
        tpu: {
        node_spec: {
            parent: "projects/PROJECT_ID/locations/europe-west4-a",
            node_id: "NODE_ID",
            node: {
            accelerator_type: "v3-8",
            runtime_version: "tpu-vm-tf-2.17.1-pod-pjrt"
            }
        }
        },
        spot: {}
    }'

控制台

  1. 在 Google Cloud 控制台中,前往「TPUs」頁面:

    前往 TPU

  2. 按一下「建立 TPU」

  3. 在「Name」欄位中,輸入 TPU 的名稱。

  4. 在「Zone」(可用區) 方塊中,選取要建立 TPU 的可用區。

  5. 在「TPU type」方塊中,選取加速器類型。加速器類型會指定要建立的 Cloud TPU 版本和大小。如要進一步瞭解各 TPU 版本支援的加速器類型,請參閱「TPU 版本」。

  6. 在「TPU 軟體版本」方塊中選取軟體版本。建立 Cloud TPU VM 時,TPU 軟體版本會指定要安裝的 TPU 執行階段版本。詳情請參閱「TPU 軟體版本」。

  7. 按一下「啟用排隊功能」切換鈕。

  8. 在「佇列資源名稱」欄位中,輸入佇列資源要求的名稱。

  9. 展開「管理」部分。

  10. 勾選「Make this a TPU Spot VM」核取方塊。

  11. 按一下 [建立]。

您也可以不使用佇列資源建立 TPU Spot VM:

gcloud

--spot 旗標新增至 gcloud compute tpus tpu-vm 指令:

gcloud compute tpus tpu-vm create TPU_NAME \
    --zone=europe-west4-a \
    --accelerator-type=v3-8 \
    --version=tpu-vm-tf-2.17.1-pod-pjrt \
    --spot

curl

scheduling_config: {spot: true} 新增至要求主體:

curl -X POST https://tpu.googleapis.com/v2/projects/PROJECT_ID/locations/europe-west4-a/nodes?node_id=TPU_NAME \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -d '{
        accelerator_type: "v3-8",
        runtime_version: "tpu-vm-tf-2.17.1-pod-pjrt",
        network_config: {enable_external_ips: true},
        scheduling_config: {spot: true}
    }'

控制台

  1. 在 Google Cloud 控制台中,前往「TPUs」頁面:

    前往 TPU

  2. 按一下「建立 TPU」

  3. 在「Name」欄位中,輸入 TPU 的名稱。

  4. 在「Zone」(可用區) 方塊中,選取要建立 TPU 的可用區。

  5. 在「TPU type」方塊中,選取加速器類型。加速器類型會指定要建立的 Cloud TPU 版本和大小。如要進一步瞭解各 TPU 版本支援的加速器類型,請參閱「TPU 版本」。

  6. 在「TPU 軟體版本」方塊中選取軟體版本。建立 Cloud TPU VM 時,TPU 軟體版本會指定要安裝的 TPU 執行階段版本。詳情請參閱「TPU 軟體版本」。

  7. 展開「管理」部分。

  8. 勾選「Make this a TPU Spot VM」核取方塊。

  9. 按一下 [建立]。

檢查 TPU VM 是否為 Spot VM

gcloud

如要確認 TPU VM 是否為 Spot VM,請使用 describe 指令:

gcloud compute tpus tpu-vm describe TPU_NAME --zone=europe-west4-a

如果 TPU VM 是 Spot VM,輸出內容就會包含 spot 欄位,並設為 true,類似於以下內容:

...
schedulingConfig:
spot: true
...

控制台

  1. 在 Google Cloud 控制台中,前往「TPUs」頁面:

    前往 TPU

  2. 按一下 Cloud TPU 的名稱。

    如果 TPU VM 是 Spot VM,則層級會是 Spot VM

定價與配額

TPU Spot VM 的價格遠低於隨選和預留 TPU。如要進一步瞭解定價,請參閱 Cloud TPU 定價

您必須有先占配額,才能使用 TPU 點播 VM。詳情請參閱「配額」。