Consume a reservation
If you have a TPU reservation, you can use your reserved resources to create TPUs that match the reservation's properties. This action is known as consuming a reservation. For information about consuming a TPU reservation when using GKE, see TPU reservation in the GKE documentation.
Consume a specific reservation
When you create resources with the gcloud alpha compute tpus queued-resources
create
command, use
the --reservation
flag
to specify the name of the reservation to consume. For future reservations
created in calendar mode, you must also set the --provisioning-model
flag
to reservation-bound
:
gcloud alpha compute tpus queued-resources create QUEUED_RESOURCE_ID \ --node-id=TPU_NAME \ --zone=ZONE \ --accelerator-type=ACCELERATOR_TYPE \ --runtime-version=SOFTWARE_VERSION \ --reservation=RESERVATION_NAME \ --provisioning-model=reservation-bound # Only required for calendar mode
Replace the following placeholder variables:
- QUEUED_RESOURCE_ID: A user-assigned ID for the queued resource request.
- TPU_NAME: A user-assigned ID (name) for the TPU that is created when the queued resource request is allocated.
- ZONE: The zone in which to create the TPU VM. For more information about supported zones, see Regions and zones.
- ACCELERATOR_TYPE: Specifies the version and size of the Cloud TPU to create. For more information about supported accelerator types for each TPU version, see TPU versions.
- SOFTWARE_VERSION: The Cloud TPU software version.
- RESERVATION_NAME: The name of the reservation to consume.
Consume any matching reservation
You can use the --reserved
flag to automatically determine the reservation to
use based on the accelerator type, project ID, and zone.
CreateNode
To consume any matching reservation using the CreateNode API, use the gcloud
alpha compute tpus tpu-vm create
command with the
--reserved
flag:
gcloud alpha compute tpus tpu-vm create TPU_NAME \ --zone=ZONE \ --accelerator-type=ACCELERATOR_TYPE \ --version=SOFTWARE_VERSION \ --reserved
Replace the following placeholder variables:
- TPU_NAME: A name for the TPU.
- ZONE: The zone in which to create the TPU VM. For more information about supported zones, see Regions and zones.
- ACCELERATOR_TYPE: Specifies the version and size of the Cloud TPU to create. For more information about supported accelerator types for each TPU version, see TPU versions.
- SOFTWARE_VERSION: The Cloud TPU software version.
Queued resources
To consume any matching reservation using queued
resources, use the gcloud alpha compute tpus
queued-resources create
command with
the --reserved
flag:
gcloud alpha compute tpus queued-resources create QUEUED_RESOURCE_ID \ --node-id=TPU_NAME \ --zone=ZONE \ --accelerator-type=ACCELERATOR_TYPE \ --runtime-version=SOFTWARE_VERSION \ --reserved
Replace the following placeholder variables:
- QUEUED_RESOURCE_ID: A user-assigned ID for the queued resource request.
- TPU_NAME: A user-assigned ID (name) for the TPU that is created when the queued resource request is allocated.
- ZONE: The zone in which to create the TPU VM. For more information about supported zones, see Regions and zones.
- ACCELERATOR_TYPE: Specifies the version and size of the Cloud TPU to create. For more information about supported accelerator types for each TPU version, see TPU versions.
- SOFTWARE_VERSION: The Cloud TPU software version.
Check reservation usage
To see how much of the reservation is in use, use the gcloud compute
reservations describe
command
gcloud compute reservations describe RESERVATION_NAME \ --project=PROJECT_ID --zone=ZONE
Replace the following placeholder variables:
- RESERVATION_NAME: The name of the reservation.
- PROJECT_ID: The ID of the project that contains the reservation.
- ZONE: The zone where the reservation exists.
To list all reservations in a project, use the gcloud compute reservations
list
command:
gcloud compute reservations list --project=PROJECT_ID
Replace the following placeholder variable:
- PROJECT_ID: The ID of the project.