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.
Retrieve Cloud TPU information
You can retrieve information about a specific Cloud TPU.
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.
Start Cloud TPU resources
You can start a stopped Cloud TPU.
The queued resources API does not support starting TPU Pods or TPUs.
Delete a Cloud TPU
Delete your TPU VM slices after your session.
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.