Compute Engine provides graphics processing units (GPUs) that you can add to your virtual machines (VMs). You can use these GPUs to accelerate specific workloads on your VMs such as machine learning and data processing.
This document provides an overview of the steps required for creating a VM with attached GPUs.
For more information about GPUs on Compute Engine, see About GPUs.
Select the GPU model
For a list of GPU models that are available, see GPU platforms. Also make a note of the machine type that is supported for the selected GPU model.
For each model, it might also be helpful to review the following:
- Supported regions and zones.
- GPU pricing to understand the cost to use each GPU model on your VMs. For VMs that use accelerator-optimized machines, also review VM instance pricing.
- Review the restrictions for VMs with GPUs.
Choose an operating system
If you are using GPUs for machine learning, you can use a Deep Learning VM Images for your VM. Each Deep Learning VM Images has a GPU driver pre-installed and include packages, such as TensorFlow and PyTorch. You can also use a Deep Learning VM Images for general GPU workloads. For information about the images available and the packages installed on the images, see Choosing an image. You can also use any public image or custom image, but some images might require a unique driver or install process that is not covered in this document.
You must identify which drivers are appropriate for your OS image. For steps to install drivers, see installing GPU drivers.
Check GPU quota
To protect Compute Engine systems and users, new projects have a global GPU quota, which limits the total number of GPUs you can create in any supported zone. To review GPU quota, see GPU quota.
If you need additional GPU quota, request a quota increase. When you request GPU quota, you must request quota for the GPU types that you want to create in each region and an additional global quota for the total number of GPUs of all types in all zones.
If your project has an established billing history, it will receive quota automatically after you submit the request.
GPU VMs and preemptible allocation quotas
Resources for VMs that use the default standard provisioning model (standard VMs) typically cannot use preemptible allocation quotas, which are intended for temporary workloads and usually more available. If your project does not have preemptible quota, and you have never requested preemptible quota, all VMs in that project consume standard allocation quotas.
However, once you request preemptible allocation quota, then the standard VMs that meet all the following criteria can consume only preemptible allocation quota.
- The VM has attached GPUs. This can either be an N1 VM that has GPUs attached, or an accelerator-optimized VM.
- The VM is configured to be automatically deleted after a predefined run time
of 7 days or less through one of the following methods:
- Using either the
maxRunDuration
field orterminationTime
field. For more information, see Limit the run time of a VM or Limit the run time of VMs in a MIG. - Using the
requestedRunDuration
field—which is only available for managed instance groups (MIGs). For more information, see About resize requests in a MIG.
- Using either the
- The VM is not allowed to consume reservations. For more information, see Create VMs without consuming reservations.
By consuming preemptible allocation quota for such workloads, you gain both the benefits of uninterrupted run time from standard VMs and improved obtainability from preemptible allocation quota.
Regardless of the quota used, standard VMs don't qualify for Spot VMs pricing and are not subject to preemption.
For more information, see Preemptible quotas.
Create a VM that has attached GPUs
To create a VM that has attached GPUs, complete the following steps:
Create the VM. The method used to create a VM depends on the GPU model selected.
- To create a VM that has attached NVIDIA H100, A100, or L4 GPUs, see Create an accelerator-optimized VM.
- To create a VM that has attached NVIDIA T4, P4, P100, or V100 GPUs, see Create an N1 VM that has attached GPUs.
For the VM to use the GPU, you need to install the GPU driver on your VM. If you enabled an NVIDIA RTX virtual workstation (formerly known as NVIDIA GRID), install a driver for virtual workstation.
What's next?
Learn more about GPU platforms.
Learn more about the features and limitations of using GPUs.
- Learn how to view the actual and forecasted usage of your GPUs.