Manage TPU resources
This page describes how to list, stop, start, delete, and connect to TPU VMs.
Prerequisites
Before you run these procedures, complete the following steps:
Create a Google Cloud project for your TPUs as described in Set up a Google Cloud project for TPUs.
Determine your TPU requirements as described in Plan your Cloud TPU resources.
Create a TPU VM as described in Create a TPU VM.
If you use one of the Cloud Client Libraries, follow the setup instructions for the language you're using:
Set up environment variables.
export TPU_NAME=your-tpu-name export ZONE=your-zone
Connect to a Cloud TPU
You can connect to a Cloud TPU using SSH.
If you can't connect to a TPU VM using SSH, the TPU VM might not have an external IP address. To access a TPU VM without an external IP address, follow the instructions in Connect to a TPU VM without a public IP address.
gcloud
Connect to your Cloud TPU using SSH:
$ gcloud compute tpus tpu-vm ssh $TPU_NAME --zone=$ZONE
When you request a slice larger than a single host, Cloud TPU creates a TPU VM for each host. The number of TPU chips per host depends on the TPU version.
To install binaries or run code, connect to each TPU VM using
the tpu-vm ssh command.
$ gcloud compute tpus tpu-vm ssh $TPU_NAME --zone=$ZONE
To connect to a specific TPU VM
using SSH, use the --worker flag with a 0-based index:
$ gcloud compute tpus tpu-vm ssh $TPU_NAME --zone=$ZONE --worker=1
To run a command on all TPU VMs, use the
--worker=all and --command flags:
$ gcloud compute tpus tpu-vm ssh $TPU_NAME \ --zone=$ZONE \ --worker=all \ --command='pip install "jax[tpu]==0.4.20" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html'
For Multislice, you can run a command on a single VM using the
enumerated TPU name, with each slice prefix and the number appended to it. To
run a command on all TPU VMs in all slices, use the --node=all, --worker=all,
and --command flags, with an optional --batch-size
flag.
$ gcloud compute tpus queued-resources ssh your-queued-resource-id \ --zone=$ZONE \ --node=all \ --worker=all \ --command='pip install jax[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html' \ --batch-size=4
When you connect to VMs using the Google Cloud CLI, Compute Engine creates a persistent SSH key.
Console
To connect to your TPUs in the Google Cloud console, use SSH in your browser:
In the Google Cloud console, go to the TPUs page:
In the list of TPU VMs, click SSH in the row of the TPU VM that you want to connect to.
When you connect to TPU VMs using the Google Cloud console, Compute Engine creates an ephemeral SSH key.
List Cloud TPU resources
You can list all Cloud TPU resources in a specified zone.
gcloud
$ gcloud compute tpus tpu-vm list --zone=$ZONE
Console
In the Google Cloud console, go to the TPUs page:
Java
To authenticate to Cloud TPU, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Node.js
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Retrieve Cloud TPU information
You can retrieve information about a specific Cloud TPU.
gcloud
$ gcloud compute tpus tpu-vm describe $TPU_NAME \ --zone=$ZONE
Console
In the Google Cloud console, go to the TPUs page:
Click the name of your Cloud TPU. The console displays the Cloud TPU details page.
Java
To authenticate to Cloud TPU, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Node.js
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Stop Cloud TPU resources
You can stop a single Cloud TPU to avoid incurring charges without losing its VM configuration and software.
The queued resources API does not support stopping TPU slices or TPUs. To stop incurring charges for TPUs allocated through the queued resources API, delete the TPU.
gcloud
$ gcloud compute tpus tpu-vm stop $TPU_NAME \ --zone=$ZONE
Console
In the Google Cloud console, go to the TPUs page:
Select the checkbox next to your Cloud TPU.
Click Stop.
Java
To authenticate to Cloud TPU, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Node.js
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Start Cloud TPU resources
You can start a stopped Cloud TPU.
The queued resources API does not support starting TPU Pods or TPUs.
gcloud
$ gcloud compute tpus tpu-vm start $TPU_NAME \ --zone=$ZONE
Console
In the Google Cloud console, go to the TPUs page:
Select the checkbox next to your Cloud TPU.
Click Start.
Java
To authenticate to Cloud TPU, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Node.js
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Delete a Cloud TPU
Delete your TPU VM slices after your session.
gcloud
$ gcloud compute tpus tpu-vm delete $TPU_NAME \ --zone=$ZONE \ --quiet
Command flag descriptions
zone: The zone where you plan to delete your Cloud TPU.quiet: Disables all interactive prompts when running gcloud CLI commands.
Console
In the Google Cloud console, go to the TPUs page:
Select the checkbox next to your Cloud TPU.
Click Delete.
Java
To authenticate to Cloud TPU, set up Application Default Credentials.
For more information, see
Set up authentication for a local development environment.
Node.js
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Cloud TPU, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
What's next
- Learn how to configure networking and access to your Cloud TPU
- Learn about queued resources.
- Learn about TPUs in GKE.
- Learn how to run JAX code on a TPU VM.
- Learn how to run PyTorch code on a TPU VM.
- Learn how to run an ML workload on TPUs: Serve Qwen2-72B-Instruct with vLLM on TPUs.