Create an AI-optimized MIG with A4 or A3 Ultra machine type (original) (raw)

Skip to main content

Create an AI-optimized MIG with A4 or A3 Ultra machine type

This document describes how to create a managed instance group (MIG) that uses A4 or A3 Ultra machine types. To learn more about these accelerator-optimized machine types, see A4 orA3 Ultra.

Creating a MIG lets you manage multiple virtual machines (VMs) as a single entity. Each VM in a MIG is based on an instance template. By automatically managing the VMs in the group, MIGs offer high availability and scalability. To learn more about MIGs, seeManaged instance groupsin the Compute Engine documentation.

To learn about other ways to create VMs or clusters, seeVM and cluster creation overviewpage.

Limitations

When you create a MIG with A4 or A3 Ultra VMs, consider the limitations for both the machine type and the MIG.

Limitations for A4 or A3 Ultra VMs

Depending on the machine series that the VMs in your MIG use, the following limitations apply:

A4

A3 Ultra

Limitations for the MIG

When you create a MIG with A4 or A3 Ultra VMs, the following limitations apply:

Limitations for MIG resize requests

For MIG resize requests, the following limitations apply:

Before you begin

Before creating a MIG, if you haven't already done so, complete the following steps:

  1. Choose a consumption option: your choice of consumption option determines how you get and use GPU resources. To learn more, seeChoose a consumption option.
  2. Obtain capacity: the process to obtain capacity differs for each consumption option. To learn about the process to obtain capacity for your chosen consumption option, seeCapacity overview.

Required roles

To get the permissions that you need to create a MIG, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to create a MIG. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create a MIG:

You might also be able to get these permissions with custom roles or other predefined roles.

Overview

Creating a MIG with the A4 or A3 Ultra machine type includes the following steps:

  1. Create VPC networks
  2. Optional: Create a workload policy
  3. Create an instance template
  4. Create a MIG

Create VPC networks

To set up the network for A4 or A3 Ultra machine types, create three VPC networks for the following network interfaces:

For more information about NIC arrangement, seeReview network bandwidth and NIC arrangement.

Create the networks either manually by following the instruction guides or automatically by using the provided script.

Instruction guides

To create the networks, you can use the following instructions:

For these VPC networks, we recommend setting themaximum transmission unit (MTU) to a larger value. For A4 or A3 Ultra machine types, the recommended MTU is 8896 bytes. To review the recommended MTU settings for other GPU machine types, seeMTU settings for GPU machine types.

Script

To create the networks, follow these steps.

For these VPC networks, we recommend setting themaximum transmission unit (MTU) to a larger value. For A4 or A3 Ultra machine types, the recommended MTU is 8896 bytes. To review the recommended MTU settings for other GPU machine types, seeMTU settings for GPU machine types.

  1. Use the following script to create VPC networks for the gVNICs and CX-7 NICs.

    #!/bin/bash

    Create regular VPC networks and subnets for the gVNICs

    for N in $(seq 0 1); do
    gcloud compute networks create GVNIC_NAME_PREFIX-net-$N \
    --subnet-mode=custom \
    --mtu=8896
    gcloud compute networks subnets create GVNIC_NAME_PREFIX-sub-$N \
    --network=GVNIC_NAME_PREFIX-net-$N \
    --region=REGION \
    --range=10.$N.0.0/16
    gcloud compute firewall-rules create GVNIC_NAME_PREFIX-internal-$N \
    --network=GVNIC_NAME_PREFIX-net-$N \
    --action=ALLOW \
    --rules=tcp:0-65535,udp:0-65535,icmp \
    --source-ranges=10.0.0.0/8
    done

    Create SSH firewall rules

    gcloud compute firewall-rules create GVNIC_NAME_PREFIX-ssh \
    --network=GVNIC_NAME_PREFIX-net-0 \
    --action=ALLOW \
    --rules=tcp:22 \
    --source-ranges=IP_RANGE

    Assumes that an external IP is only created for vNIC 0

    gcloud compute firewall-rules create GVNIC_NAME_PREFIX-allow-ping-net-0 \
    --network=GVNIC_NAME_PREFIX-net-0 \
    --action=ALLOW \
    --rules=icmp \
    --source-ranges=IP_RANGE

    #!/bin/bash

    List and make sure network profiles exist in the machine type's zone

    gcloud compute network-profiles list --filter "location.name=ZONE"

    Create network for RDMA NICs

    gcloud compute networks create RDMA_NAME_PREFIX-mrdma \
    --network-profile=ZONE-vpc-roce \
    --subnet-mode custom \
    --mtu=8896

    Create subnets

    for N in $(seq 0 7); do
    gcloud compute networks subnets create RDMA_NAME_PREFIX-mrdma-sub-$N \
    --network=RDMA_NAME_PREFIX-mrdma \
    --region=REGION \
    --range=10.$((N+2)).0.0/16 # offset to avoid overlap with gVNICs
    done

Replace the following:

  1. Optional: To verify that the VPC network resources are created successfully, check the network settings in the Google Cloud console:
    1. In the Google Cloud console, go to the VPC networks page.
      Go to VPC networks
    2. Search the list for the networks that you created in the previous step.
    3. To view the subnets, firewall rules, and other network settings, click the name of the network.

Optional: Create a workload policy

If you want your VMs to be placed in a single or adjacent blocks, then specify VM placement by creating aworkload policy. However, if you want Compute Engine to place your VMs on a specific block, skip this step and provide the name of the block in the reservation affinity when you create the instance template.

To create a workload policy, select one of the following options:

gcloud

To create a workload policy, use the gcloud compute resource-policies create workload-policy command.

Replace the following:

REST

To create a workload policy, make a POSTrequest to the resourcePolicies.insert method.

Replace the following:

Create an instance template

Specify the VM properties for a MIG by creating an instance template.

To create an instance template, select one of the following options:

The following commands also set the access scope for your instances. To simplify permissions management, Google recommends that you set the access scope on an instance tocloud-platform access and then use IAM roles to define what services the instance can access. For more information, seeScopes best practice.

gcloud

The parameters that you need to specify depend on theconsumption option that you are using for this deployment. Select the tab that corresponds to your consumption option's provisioning model.

Flex-start

To create a regional instance template, use the gcloud compute instance-templates create command.

gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME
--machine-type=MACHINE_TYPE
--image-family=IMAGE_FAMILY
--image-project=IMAGE_PROJECT
--instance-template-region=REGION
--boot-disk-type=hyperdisk-balanced
--boot-disk-size=DISK_SIZE
--scopes=cloud-platform
--network-interface=nic-type=GVNIC,network=GVNIC_NAME_PREFIX-net-0,subnet=GVNIC_NAME_PREFIX-sub-0
--network-interface=nic-type=GVNIC,network=GVNIC_NAME_PREFIX-net-1,subnet=GVNIC_NAME_PREFIX-sub-1,no-address --network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-0,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-1,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-2,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-3,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-4,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-5,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-6,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-7,no-address
--reservation-affinity=none
--instance-termination-action=DELETE
--max-run-duration=RUN_DURATION
--maintenance-policy=TERMINATE
--provisioning-model=FLEX_START

Replace the following:

Reservation-bound

To create a regional instance template, use the gcloud compute instance-templates create command.

gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME
--machine-type=MACHINE_TYPE
--image-family=IMAGE_FAMILY
--image-project=IMAGE_PROJECT
--instance-template-region=REGION
--boot-disk-type=hyperdisk-balanced
--boot-disk-size=DISK_SIZE
--scopes=cloud-platform
--network-interface=nic-type=GVNIC,network=GVNIC_NAME_PREFIX-net-0,subnet=GVNIC_NAME_PREFIX-sub-0
--network-interface=nic-type=GVNIC,network=GVNIC_NAME_PREFIX-net-1,subnet=GVNIC_NAME_PREFIX-sub-1,no-address --network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-0,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-1,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-2,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-3,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-4,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-5,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-6,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-7,no-address
--reservation-affinity=specific
--reservation=RESERVATION
--provisioning-model=RESERVATION_BOUND
--instance-termination-action=DELETE
--maintenance-policy=TERMINATE
--restart-on-failure

Replace the following:

Spot

To create a regional instance template, use the gcloud compute instance-templates create command.

gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME
--machine-type=MACHINE_TYPE
--image-family=IMAGE_FAMILY
--image-project=IMAGE_PROJECT
--instance-template-region=REGION
--boot-disk-type=hyperdisk-balanced
--boot-disk-size=DISK_SIZE
--scopes=cloud-platform
--network-interface=nic-type=GVNIC,network=GVNIC_NAME_PREFIX-net-0,subnet=GVNIC_NAME_PREFIX-sub-0
--network-interface=nic-type=GVNIC,network=GVNIC_NAME_PREFIX-net-1,subnet=GVNIC_NAME_PREFIX-sub-1,no-address --network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-0,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-1,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-2,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-3,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-4,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-5,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-6,no-address
--network-interface=nic-type=MRDMA,network=RDMA_NAME_PREFIX-mrdma,subnet=RDMA_NAME_PREFIX-mrdma-sub-7,no-address
--provisioning-model=SPOT
--instance-termination-action=TERMINATION_ACTION
--maintenance-policy=TERMINATE
--no-restart-on-failure

Replace the following:

REST

The parameters that you need to specify depend on theconsumption option that you are using for this deployment. Select the tab that corresponds to your consumption option's provisioning model.

Flex-start

To create a regional instance template, make a POST request to the regionInstanceTemplates.insert method.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates { "name":"INSTANCE_TEMPLATE_NAME", "properties":{ "machineType":"MACHINE_TYPE", "disks":[ { "boot":true, "initializeParams":{ "diskSizeGb":"DISK_SIZE", "diskType":"hyperdisk-balanced", "sourceImage":"projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY" }, "mode":"READ_WRITE", "type":"PERSISTENT" } ], "serviceAccounts": [ { "email": "default", "scopes": [ "https://www.googleapis.com/auth/cloud-platform" ] } ], "networkInterfaces": [ { "accessConfigs": [ { "name": "external-nat", "type": "ONE_TO_ONE_NAT" } ], "network": "projects/NETWORK_PROJECT_ID/global/networks/GVNIC_NAME_PREFIX-net-0", "nicType": "GVNIC", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/GVNIC_NAME_PREFIX-sub-0" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/GVNIC_NAME_PREFIX-net-1", "nicType": "GVNIC", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/GVNIC_NAME_PREFIX-sub-1" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-0" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-1" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-2" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-3" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-4" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-5" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-6" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-7" } ], "reservationAffinity": { "consumeReservationType": "NO_RESERVATION" }, "scheduling": { "instanceTerminationAction": "DELETE", "maxRunDuration": { "seconds": RUN_DURATION }, "onHostMaintenance": "TERMINATE", "provisioningModel": "FLEX_START" }

} }

Replace the following:

Reservation-bound

To create a regional instance template, make a POST request to the regionInstanceTemplates.insert method.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates { "name":"INSTANCE_TEMPLATE_NAME", "properties":{ "machineType":"MACHINE_TYPE", "disks":[ { "boot":true, "initializeParams":{ "diskSizeGb":"DISK_SIZE", "diskType":"hyperdisk-balanced", "sourceImage":"projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY" }, "mode":"READ_WRITE", "type":"PERSISTENT" } ], "serviceAccounts": [ { "email": "default", "scopes": [ "https://www.googleapis.com/auth/cloud-platform" ] } ], "networkInterfaces": [ { "accessConfigs": [ { "name": "external-nat", "type": "ONE_TO_ONE_NAT" } ], "network": "projects/NETWORK_PROJECT_ID/global/networks/GVNIC_NAME_PREFIX-net-0", "nicType": "GVNIC", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/GVNIC_NAME_PREFIX-sub-0" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/GVNIC_NAME_PREFIX-net-1", "nicType": "GVNIC", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/GVNIC_NAME_PREFIX-sub-1" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-0" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-1" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-2" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-3" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-4" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-5" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-6" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-7" } ], "reservationAffinity":{ "consumeReservationType":"SPECIFIC_RESERVATION", "key":"compute.googleapis.com/reservation-name", "values":[ "RESERVATION" ] }, "scheduling":{ "provisioningModel":"RESERVATION_BOUND", "instanceTerminationAction":"DELETE", "onHostMaintenance": "TERMINATE", "automaticRestart":true } } }

Replace the following:

Spot

To create a regional instance template, make a POST request to the regionInstanceTemplates.insert method.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates { "name":"INSTANCE_TEMPLATE_NAME", "properties":{ "machineType":"MACHINE_TYPE", "disks":[ { "boot":true, "initializeParams":{ "diskSizeGb":"DISK_SIZE", "diskType":"hyperdisk-balanced", "sourceImage":"projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY" }, "mode":"READ_WRITE", "type":"PERSISTENT" } ], "serviceAccounts": [ { "email": "default", "scopes": [ "https://www.googleapis.com/auth/cloud-platform" ] } ], "networkInterfaces": [ { "accessConfigs": [ { "name": "external-nat", "type": "ONE_TO_ONE_NAT" } ], "network": "projects/NETWORK_PROJECT_ID/global/networks/GVNIC_NAME_PREFIX-net-0", "nicType": "GVNIC", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/GVNIC_NAME_PREFIX-sub-0" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/GVNIC_NAME_PREFIX-net-1", "nicType": "GVNIC", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/GVNIC_NAME_PREFIX-sub-1" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-0" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-1" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-2" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-3" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-4" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-5" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-6" }, { "network": "projects/NETWORK_PROJECT_ID/global/networks/RDMA_NAME_PREFIX-mrdma", "nicType": "MRDMA", "subnetwork": "projects/NETWORK_PROJECT_ID/region/REGION/subnetworks/RDMA_NAME_PREFIX-mrdma-sub-7" } ], "scheduling": { "provisioningModel": "SPOT", "instanceTerminationAction": "TERMINATION_ACTION", "onHostMaintenance": "TERMINATE", "automaticRestart": false } } }

Replace the following:

After you create the instance template, you canview itto see its ID and review its instance properties.

Create a MIG

After you complete all the previous steps, create a MIG based on your scenario as follows:

Scenario Method to create a MIG and VMs in it Example
You have multiple or parallel jobs that can start with any number of VMs. Create a MIG and use the target size to specify the number of VMs that you want in the group.See Create a MIG with a target size. ML inference jobs
You have a job that requires distribution across an exact number of VMs. Create a MIG without any VMs in it, and then create a resize request in the MIG. The resize request helps you to obtain VMs all at once. See Create a MIG and a resize request. Distributed ML training and fine-tuning jobs

Create a MIG with a target size

If you can start your job without creating all of the VMs at once, then create a MIG with a target size. The target size determines the number of VMs in the MIG. The MIG starts creating VMs based on current resource availability. If any resources are temporarily unavailable, then the MIG continuously attempts to create VMs to meet the target size.

To create a MIG with a target size, select one of the following options:

gcloud

To create a MIG with a specified target size, use theinstance-groups managed create command.

The commands that you use to create a MIG use a workload policy to specify instance placement. If you don't want to use a workload policy, then remove the --workload-policy flag.

Create a zonal or regional MIG as follows:

REST

To create a MIG with a specified target size, make a POST request.

The requests that you use to create a MIG use a workload policy to specify instance placement. If you don't want to use a workload policy, then remove the resourcePolicies.workloadPolicyfield.

Create a zonal or regional MIG as follows:

Create a MIG and a resize request

If you require multiple VMs all at once to start a job, then create a MIG, and create aresize request in the MIG as described in this section.

To create a resize request in a MIG, select one of the following options:

gcloud

The parameters that you need to specify depend on theconsumption option that you are using for this deployment. Select the tab that corresponds to your consumption option's provisioning model.

Flex-start

Create a zonal or regional MIG and a resize request as follows:

Reservation-bound

The commands that you use to create a MIG use a workload policy to specify instance placement. If you don't want to use a workload policy, then remove the --workload-policy flag.

Create a zonal or regional MIG and a resize request as follows:

Spot

The commands that you use to create a MIG use a workload policy to specify instance placement. If you don't want to use a workload policy, then remove the --workload-policy flag.

Create a zonal or regional MIG and a resize request as follows:

Replace the following:

Create a resize request by specifying a list of VM names

If your workload requires specific VM names, then specify a list of names to create the VMs. The number of names that you specify determines the number of VMs that the MIG creates all at once.

To create a resize request with specific VM names in a MIG, use thebeta gcloud compute instance-groups managed resize-requests create commandwith the --instances flag:

REST

The parameters that you need to specify depend on theconsumption option that you are using for this deployment. Select the tab that corresponds to your consumption option's provisioning model.

Flex-start

Create a zonal or regional MIG and a resize request as follows:

Reservation-bound

The requests that you use to create a MIG use a workload policy to specify instance placement. If you don't want to use a workload policy, then remove the resourcePolicies.workloadPolicyfield.

Create a zonal or regional MIG and a resize request as follows:

Spot

The requests that you use to create a MIG use a workload policy to specify instance placement. If you don't want to use a workload policy, then remove the resourcePolicies.workloadPolicyfield.

Create a zonal or regional MIG and a resize request as follows:

Replace the following:

Create a resize request by specifying a list of VM names

If your workload requires specific VM names, then specify a list of names to create the VMs. The number of names that you specify determines the number of VMs that the MIG creates all at once.

To create a resize request with specific VM names in a MIG, use one of the following methods:

For example, to specify two VM names, include the following in the request body:

{ "name": "RESIZE_REQUEST_NAME", "instances": [ { "name": "INSTANCE_NAME_1" }, { "name": "INSTANCE_NAME_2" } ] }

Replace INSTANCE_NAME_1, INSTANCE_NAME_2 with the names for the VMs.

What's next?

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-06-15 UTC.