# Deploying and Connecting to Google TPU Instances via GCloud CLI

## Context

We assume the reader has already created a Google Cloud Platform (GCP) user or organization account and an
associated project.

We also assume the reader to have the Google Cloud CLI installed. If not, please follow the links right after to
[install](https://cloud.google.com/sdk/docs/install) and [setup](https://cloud.google.com/sdk/docs/initializing).

## Creating the initial TPU VM on GCP

In order to create your initial TPU instance, you will need to provide some information:

- The [GCP zone](https://cloud.google.com/tpu/docs/regions-zones) you would like to see the instance being deployed (close to the reader for development purposes, close to the end user for production, for instance)
- Which kind of [TPU](https://cloud.google.com/tpu/docs/system-architecture-tpu-vm#versions) you would like to target
- Which version of the [TPU runtime](https://cloud.google.com/tpu/docs/runtimes) you want to leverage on the instance
- Custom instance name to quickly skim and refer back to the instance

Overall, the end command looks like this:

```bash
gcloud compute tpus tpu-vm create  \
--zone= \
--accelerator-type= \
--version=
```

### Deploying a TPU v5litepod-8 instance

In our case, we will be deploying a `v5litepod-8` instance name `optimum-tpu-get-started`
in the GCP region `us-west4-a` using the latest `v2-alpha-tpuv5-lite` runtime version.

Of course, feel free to adjust all these parameters to the one that match with your usage and quotas.

Before creating the instance, please make sure to install `gcloud alpha component` as it is required to be able to
target TPUv5 VMs: `gcloud components install alpha`

```bash
gcloud alpha compute tpus tpu-vm create optimum-tpu-get-started \
--zone=us-west4-a \
--accelerator-type=v5litepod-8 \
--version=v2-alpha-tpuv5-lite
```

## Connecting to the instance via ssh

```bash
gcloud compute tpus tpu-vm ssh  --zone=
$ >
```

In the example above deploying v5litepod-8 it would be something like:

```bash
gcloud compute tpus tpu-vm ssh optimum-tpu-get-started --zone=us-west4-a
$ >
```

## Other useful commands

This is used to get information about the tpu-vm for example its external IP:
```bash
gcloud compute tpus tpu-vm describe --zone= 
```

## Next steps
- If you wish to train your own model, you can now [install optimum-tpu](../installation)
- If you wish do to serving, you can look at our [serving tutorial](../tutorials/inference_on_tpu)