TPU Spot VM を管理する

Spot VM では、未使用の容量を大幅な割引料金で利用できます。Spot VM はいつでもプリエンプト(シャットダウン)できますが、プリエンプティブル TPU とは異なりランタイム時間に上限はありません。TPU Spot VM は再起動できません。プリエンプション後に再作成する必要があります。一般的な Spot VM の詳細については、Spot VM に関する Compute Engine のドキュメントをご覧ください。

TPU Spot VM を作成する

キューに格納されたリソースを使用して TPU Spot VM を作成できます。これにより、作成リクエストがキューに追加され、容量が使用可能になるとそれを受け取ることができます。TPU をキューに格納されたリソースとして作成することをおすすめします。詳細については、キューに格納されたリソースのユーザーガイドをご覧ください。

キューに格納されたリソースの作成コマンドに --spot フラグを追加して、TPU Spot VM をキューに格納されたリソースとして作成します。

gcloud

gcloud alpha 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.16.1-pod-pjrt \
  --spot

curl

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.16.1-pod-pjrt"
        }
      }
    },
    spot: {}
  }'

create コマンドに --spot フラグを追加すると、キューに格納されたリソースを使用せずに TPU Spot VM を作成することもできます。

gcloud

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

curl

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.16.1-pod-pjrt",
    network_config: {enable_external_ips: true},
    scheduling_config: {spot: true}
  }'

TPU VM が Spot VM かどうかを確認する

TPU VM が Spot VM かどうかを確認するには、describe コマンドを使用します。

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

TPU VM が Spot VM の場合、出力には次のように true に設定された spot フィールドが含まれます。

...
schedulingConfig:
  spot: true
...

料金と割り当て

TPU Spot VM の料金は、オンデマンド TPU や予約済み TPU の料金よりかなり低価格です。料金の詳細については、Cloud TPU の料金をご覧ください。

TPU Spot VM を使用するには、プリエンプティブルの割り当てが必要です。詳しくは、割り当てをご覧ください。