Create an AI-optimized N1 instance with GPUs

This document describes the steps to create standalone virtual machine (VM) instances that use the N1 series with attached GPUs. To learn more about these machine types, see N1 series.

To learn about other ways to create VMs or clusters, see Deployment options overview.

Limitations

For the limitations that apply to N1 machine types with GPUs, see all of the following:

Before you begin

Before creating VMs, 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, see Choose 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, see Capacity overview.

Select the tab for how you plan to use the samples on this page:

Console

When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

gcloud

In the Google Cloud console, activate Cloud Shell.

Activate Cloud Shell

At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

REST

To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

    Install the Google Cloud CLI.

    If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

For more information, see Authenticate for using REST in the Google Cloud authentication documentation.

Required roles

To get the permissions that you need to create VMs, ask your administrator to grant you the Compute 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 VMs. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create VMs:

  • compute.instances.create on the project
  • To use a custom image to create the VM: compute.images.useReadOnly on the image
  • To use a snapshot to create the VM: compute.snapshots.useReadOnly on the snapshot
  • To use an instance template to create the VM: compute.instanceTemplates.useReadOnly on the instance template
  • To specify a subnet for your VM: compute.subnetworks.use on the project or on the chosen subnet
  • To specify a static IP address for the VM: compute.addresses.use on the project
  • To assign an external IP address to the VM when using a VPC network: compute.subnetworks.useExternalIp on the project or on the chosen subnet
  • To assign a legacy network to the VM: compute.networks.use on the project
  • To assign an external IP address to the VM when using a legacy network: compute.networks.useExternalIp on the project
  • To set VM instance metadata for the VM: compute.instances.setMetadata on the project
  • To set tags for the VM: compute.instances.setTags on the VM
  • To set labels for the VM: compute.instances.setLabels on the VM
  • To set a service account for the VM to use: compute.instances.setServiceAccount on the VM
  • To create a new disk for the VM: compute.disks.create on the project
  • To attach an existing disk in read-only or read-write mode: compute.disks.use on the disk
  • To attach an existing disk in read-only mode: compute.disks.useReadOnly on the disk

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

Overview

Creating an instance with the N1 with T4 or V100 GPUs machine type includes the following steps:

  1. Create an instance
  2. Install GPU drivers

Create an N1 with GPUs VM

To create an N1 VM with GPUs, use one of the following methods.

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 to cloud-platform access and then use IAM roles to define what services the instance can access. For more information, see Scopes best practice.

Console

  1. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  2. Specify a Name for your VM. See Resource naming convention.

  3. Select the Region and Zone where you want to create a VM. See the list of available GPU regions and zones.

  4. Click the GPUs tab, and then complete the following steps:

    1. In the GPU type list, select your GPU type.
      • For N1+T4 machine types, select NVIDIA T4
      • For N1+V100 machine types, select NVIDIA V100
    2. In the Machine type list, select your N1 machine type.
    3. In the Number of GPUs list, select a number of GPUs. The available options vary based on the N1 machine type that you selected.
  5. Based on the consumption option that you want to use, select one of the following options and complete the following steps.

    Reservation

    N1 with T4 or V100 GPUs instances support the following types of reservations:

    • On-demand reservations
    • Standard future reservations

    To consume these types of reservations, an instance must use the standard provisioning model. For example, use the following creation parameters.

    1. In the Provisioning model section, in the VM provisioning model list, select