Share a Cloud TPU reservation

This document describes how to enable reservation sharing. Reservation sharing lets you create TPU VMs in one project (a consumer project) and use a reservation that another project (the owner project) owns. Reservation sharing also lets you run custom training or prediction jobs in Vertex AI using a TPU reservation.

The owner project is the project where you created the reservation. Consumer projects are one or more projects that share the reservation. You can create TPU VMs in the owner project and consumer projects using the reservation in the owner project.

For more information about obtaining a TPU reservation, see About Cloud TPU reservations .

Limitations

Before you share a TPU reservation, consider the following:

  • You can modify a shared reservation only from its owner project.

  • You can modify a short-term reservation in calendar mode or long-term reservation only as follows:

    • You can modify the reservation only after its start time.

    • You can modify the reservation only to allow or disallow jobs in Vertex AI from consuming it.

The following sections describe the different methods to share a reservation.

Enable sharing of a TPU reservation

You can create TPU VMs in a consumer project using a reservation that another project owns. All projects that share a TPU reservation must be part of the same organization .

To enable sharing of a TPU reservation:

  1. Grant permission to the owner project to create and modify shared reservations using the gcloud resource-manager org-policies allow command :

    gcloud  
    resource-manager  
    org-policies  
    allow  
     \ 
      
    compute.sharedReservationsOwnerProjects  
     \ 
      
    projects/ OWNER_PROJECT_NUMBER 
      
    --organization = 
     ORGANIZATION_ID 
    

    Replace the following:

    • OWNER_PROJECT_NUMBER : The project number (not project ID) of a project in your organization that you want to allow to create and modify shared reservations.
    • ORGANIZATION_ID : The organization resource ID of your organization.
  2. Enable CUD sharing through the Google Cloud console. For instructions, see Enable CUD sharing for resource-based commitments .

  3. To enable sharing, use the gcloud beta compute reservations update command with the --share-setting=projects and --share-with flags:

    gcloud  
    beta  
    compute  
    reservations  
    update  
     RESERVATION_NAME 
      
     \ 
      
    --project = 
     OWNER_PROJECT_ID 
      
     \ 
      
    --share-setting = 
    projects  
     \ 
      
    --share-with = 
     CONSUMER_PROJECT_IDS 
      
     \ 
      
    --zone = 
     ZONE 
    

    Replace the following:

    • RESERVATION_NAME : The name of the reservation.
    • OWNER_PROJECT_ID : The ID of the project that contains the reservation.
    • CONSUMER_PROJECT_IDS : A comma-separated list of IDs of projects that can consume this reservation. For example, project-1,project-2 . You can include up to 100 consumer projects. These projects must be in the same organization as the owner project. Don't include the owner project. By default, the owner project is already allowed to consume the reservation.
    • ZONE : The zone where the reservation is located.

Disable sharing of a TPU reservation

To disable sharing a TPU reservation with a list of consumer projects, use the gcloud beta compute reservations update command with the --share-setting=projects and --remove-share-with flags:

gcloud  
compute  
reservations  
update  
 RESERVATION_NAME 
  
 \ 
  
--project = 
 OWNER_PROJECT_ID 
  
 \ 
  
--share-setting = 
projects  
 \ 
  
--remove-share-with = 
 CONSUMER_PROJECT_IDS 
  
 \ 
  
--zone = 
 ZONE 

Replace the following:

  • RESERVATION_NAME : The name of the reservation.
  • OWNER_PROJECT_ID : The ID of the project that contains the reservation.
  • CONSUMER_PROJECT_IDS : A comma-separated list of IDs of projects that you want to stop sharing the reservation with. For example, project-1,project-2 .
  • ZONE : The zone where the reservation is located.

To disable sharing a TPU reservation with all consumer projects, change the reservation to a local reservation using the gcloud beta compute reservations update command with the --share-setting=local flag:

gcloud  
beta  
compute  
reservations  
update  
 RESERVATION_NAME 
  
 \ 
  
--project = 
 OWNER_PROJECT_ID 
  
 \ 
  
--share-setting = 
 local 
  
 \ 
  
--zone = 
 ZONE 

Replace the following:

  • RESERVATION_NAME : The name of the reservation.
  • OWNER_PROJECT_ID : The ID of the project that contains the reservation.
  • ZONE : The zone where the reservation is located.

You can allow training or prediction jobs in Vertex AI to consume a short-term reservation in calendar mode or long-term reservation only after its start time.

To allow Vertex AI to consume a TPU reservation, use the gcloud beta compute reservations update command with the --reservation-sharing-policy=ALLOW_ALL flag:

gcloud  
beta  
compute  
reservations  
update  
 RESERVATION_NAME 
  
 \ 
  
--project = 
 OWNER_PROJECT_ID 
  
 \ 
  
--zone = 
 ZONE 
  
 \ 
  
--reservation-sharing-policy = 
ALLOW_ALL

Replace the following:

  • RESERVATION_NAME : The name of the reservation.
  • OWNER_PROJECT_ID : The ID of the project that contains the reservation.
  • ZONE : The zone of the reservation.

Disallow Vertex AI to use a TPU reservation

Before you disallow Vertex AI from consuming a TPU reservation, stop any Vertex AI jobs that use it. Otherwise, you encounter errors.

To disallow Vertex AI from consuming a TPU reservation, use the gcloud beta compute reservations update command with the --reservation-sharing-policy=DISALLOW_ALL flag:

gcloud  
beta  
compute  
reservations  
update  
 RESERVATION_NAME 
  
 \ 
  
--project = 
 OWNER_PROJECT_ID 
  
 \ 
  
--zone = 
 ZONE 
  
 \ 
  
--reservation-sharing-policy = 
DISALLOW_ALL

Replace the following:

  • RESERVATION_NAME : The name of the reservation.
  • OWNER_PROJECT_ID : The ID of the project that contains the reservation.
  • ZONE : The zone of the reservation.

Get information about a shared reservation

You can get information about a shared reservation only from its owner project.

To get information about a shared reservation, use the gcloud compute reservations describe command :

gcloud  
compute  
reservations  
describe  
 RESERVATION_NAME 
  
 \ 
  
--project = 
 OWNER_PROJECT_ID 
  
 \ 
  
--zone = 
 ZONE 

Replace the following:

  • RESERVATION_NAME : The name of the reservation.
  • OWNER_PROJECT_ID : The ID of the project that contains the reservation.
  • ZONE : The zone of the reservation.

The response is similar to the following:

aggregateReservation: [ 
... ] 
name:  
 RESERVATION_NAME 
reservationSharingPolicy:  
 serviceShareType:  
ALLOW_ALL 
resourceStatus:  
 {} 
selfLink:  
https://www.googleapis.com/compute/v1/projects/ OWNER_PROJECT_ID 
/zones/ ZONE 
/reservations/ RESERVATION_NAME 
shareSettings:  
 projectMap:  
 ' CONSUMER_PROJECT_1 
' 
:  
projectId:  
 ' CONSUMER_PROJECT_1 
' 
  
 ' CONSUMER_PROJECT_2 
' 
:  
projectId:  
 ' CONSUMER_PROJECT_2 
' 
  
shareType:  
SPECIFIC_PROJECTS 
specificReservationRequired:  
 true 
status:  
READY
zone:  
https://www.googleapis.com/compute/v1/projects/ OWNER_PROJECT_ID 
/zones/ ZONE 

What's next

Design a Mobile Site
View Site in Mobile | Classic
Share by: