[ Web Proxy ]
URL:
Viewing: https://cloud.google.com/tpu/docs/create-instance-compute [Back]  [Original]

Create a Cloud TPU VM instance using Compute Engine  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback Stay organized with collections Save and categorize content based on your preferences.

Create a Cloud TPU VM instance using Compute Engine

This document shows you how to create a single TPU VM with the Compute Engine gcloud compute instances create command. You can also create a TPU VM instance by specifying an instance template. For more information, see Create a VM from an instance template.

Prerequisites

Complete the following prerequisites:

  1. Create a Google Cloud project for your TPUs as described in Set up a Google Cloud project for TPUs.

  2. Determine your TPU requirements as described in Plan your Cloud TPU resources.

Create a TPU VM instance

The parameters you use to create a TPU VM instance depend on the consumption option you are using: on-demand, Spot, reservation-bound, or flex-start. For more information, see Plan your TPU resources .

Create an on-demand TPU VM instance

To create an on-demand TPU VM instance, use the gcloud compute instances create command:

Important: When you use the ct6e-standard-8t machine type, you must set the threads per core to 1 by including the --threads-per-core=1 flag in the following command. For more information on threads per core, see Set the number of threads per core.

gcloud

gcloud compute instances create TPU_NAME \
  --machine-type=MACHINE_TYPE \
  --image-family=IMAGE_FAMILY \
  --image-project=IMAGE_PROJECT \
  --zone=ZONE \
  --maintenance-policy=TERMINATE

REST

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "TPU_NAME",
    "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
    "disks": [
      {
        "boot": true,
        "initializeParams": {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY"
        }
      }
    ],
    "scheduling": {
      "onHostMaintenance": "TERMINATE"
    },
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ]
  }' \
  "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"

Replace the following placeholders:

Create a TPU Spot VM instance

To create a TPU Spot VM instance, use the gcloud compute instances create command with the --provisioning-model=SPOT flag:

Important: When you use the ct6e-standard-8t machine type, you must set the threads per core to 1 by including the --threads-per-core=1 flag in the following command. For more information on threads per core, see Set the number of threads per core.

gcloud

gcloud compute instances create TPU_NAME \
  --machine-type=MACHINE_TYPE \
  --image-family=IMAGE_FAMILY \
  --image-project=IMAGE_PROJECT \
  --zone=ZONE \
  --provisioning-model=SPOT \
  --instance-termination-action=DELETE \
  --maintenance-policy=TERMINATE

REST

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "TPU_NAME",
    "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
    "disks": [
      {
        "boot": true,
        "initializeParams": {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY"
        }
      }
    ],
    "scheduling": {
      "onHostMaintenance": "TERMINATE",
      "provisioningModel": "SPOT",
      "instanceTerminationAction": "DELETE"
    },
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ]
  }' \
  "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"

Replace the following placeholders:

Create a TPU VM instance using a reservation

To create a TPU VM instance using the reservation-bound consumption option, use the gcloud compute instances create command with the --reservation-affinity=specific and --reservation flags:

Important: When you use the ct6e-standard-8t machine type, you must set the threads per core to 1 by including the --threads-per-core=1 flag in the following command. For more information on threads per core, see Set the number of threads per core.

gcloud

gcloud compute instances create TPU_NAME \
  --machine-type=MACHINE_TYPE \
  --image-family=IMAGE_FAMILY \
  --image-project=IMAGE_PROJECT \
  --zone=ZONE \
  --provisioning-model=reservation-bound \
  --reservation-affinity=specific \
  --reservation=RESERVATION_NAME \
  --instance-termination-action=DELETE \
  --maintenance-policy=TERMINATE

REST

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "TPU_NAME",
    "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
    "disks": [
      {
        "boot": true,
        "initializeParams": {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY"
        }
      }
    ],
    "scheduling": {
      "onHostMaintenance": "TERMINATE",
      "provisioningModel": "RESERVATION_BOUND",
      "instanceTerminationAction": "DELETE"
    },
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ],
    "reservationAffinity": {
      "consumeReservationType": "SPECIFIC_RESERVATION",
      "key": "compute.googleapis.com/reservation-name",
      "values": [
        "RESERVATION_NAME"
      ]
    }
  }' \
  "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"

Replace the following placeholders:

Create a TPU Flex-start VM

To create a TPU Flex-start VM instance, use the gcloud compute instances create command with the --provisioning-model=FLEX_START flag:

Important: When you use the ct6e-standard-8t machine type, you must set the threads per core to 1 by including the --threads-per-core=1 flag in the following command. For more information on threads per core, see Set the number of threads per core.

gcloud

gcloud compute instances create TPU_NAME \
  --machine-type=MACHINE_TYPE \
  --image-family=IMAGE_FAMILY \
  --image-project=IMAGE_PROJECT \
  --zone=ZONE \
  --provisioning-model=FLEX_START \
  --max-run-duration=MAX_RUN_DURATION \
  --request-valid-for-duration=VALID_DURATION \
  --instance-termination-action=DELETE \
  --maintenance-policy=TERMINATE

REST

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "TPU_NAME",
    "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",
    "disks": [
      {
        "boot": true,
        "initializeParams": {
          "sourceImage": "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY"
        }
      }
    ],
    "params": {
      "requestValidForDuration": {
        "seconds": VALID_DURATION
      }
    },
    "scheduling": {
      "onHostMaintenance": "TERMINATE",
      "provisioningModel": "FLEX_START",
      "instanceTerminationAction": "DELETE",
      "maxRunDuration": {
        "seconds": MAX_RUN_DURATION
      }
    },
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ]
  }' \
  "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"

Replace the following placeholders:

For more information about creating Compute Engine instances, see Create and start a Compute Engine instance.

What's next

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page