Stay organized with collections Save and categorize content based on your preferences.
Linux Windows
Compute Engine provides graphics processing units (GPUs) that you can add to your virtual machine (VM) instances. You can use these GPUs to accelerate specific workloads on your VMs such as machine learning and data processing.
You can only use two machine families when running GPUs on Compute Engine:
Select the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
RESTTo 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. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
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.
Each accelerator-optimized machine type has a specific model of NVIDIA GPUs attached. If you have graphics-intensive workloads, such as 3D visualization, you can also create virtual workstations that use NVIDIA RTX Virtual Workstations (vWS). NVIDIA RTX Virtual Workstation is available for some GPU models.
Machine type GPU model NVIDIA RTX Virtual Workstation (vWS) model A4X NVIDIA GB200 Grace Blackwell Superchips (nvidia-gb200
).
Each Superchip contains four NVIDIA B200 Blackwell GPUs.
A4 NVIDIA B200 Blackwell GPUs (nvidia-b200
) A3 Ultra NVIDIA H200 SXM GPUs (nvidia-h200-141gb
) A3 Mega NVIDIA H100 SXM GPUs (nvidia-h100-mega-80gb
) A3 High, A3 Edge NVIDIA H100 SXM GPUs (nvidia-h100-80gb
) A2 Ultra NVIDIA A100 80GB GPUs (nvidia-a100-80gb
) A2 Standard NVIDIA A100 40GB GPUs (nvidia-a100-40gb
) G4 (Preview) NVIDIA RTX PRO 6000 Blackwell Server Edition (nvidia-rtx-pro-6000
) G2 NVIDIA L4 GPUs (nvidia-l4
) NVIDIA L4 Virtual Workstation GPUs (nvidia-l4-vws
)
You can modify each accelerator-optimized VM as follows:
For A2 Ultra, A3, and A4 VMs, you can't modify the machine type. If you are using any of these machine types for your VM and you need to change the machine type, create a new VM.
For A2 Standard VMs, you can modify the GPU count by switching from one A2 Standard machine type to another A2 Standard machine type.
For G2 VMs, you can do the following:
You can't remove GPUs from any of the accelerator-optimized machine type. If you no longer require GPUs, complete the following:
You can modify the GPU count of an A2 standard or G2 accelerator-optimized VM by using either the Google Cloud console, or REST.
ConsoleYou can modify the number of GPUs for your VM by stopping the VM and editing the VM configuration.
Verify that all of your critical applications are stopped on the VM.
In the Google Cloud console, go to the VM instances page to see your list of VMs.
Click the name of the VM that you want to modify the number of GPUs for. The Details page opens.
Complete the following steps from the Details page.
If the VM is running, click stop Stop to stop the VM. If there is no Stop option, click more_vert More actions > stop Stop.
Click edit Edit.
In the Machine configuration section, select the GPUs machine family, and then do the following:
In the Number of GPUs list, increase or decrease the GPU count.
Note: Each accelerator-optimized machine type has a specific number of GPUs attached. If you adjust the number of GPUs, the machine type changes.To apply your changes, click Save.
To restart the VM, click Start/Resume.
You can modify the number of GPUs on your VM by stopping the VM and changing the machine type. Each accelerator-optimized machine type has a specific number of GPUs attached. If you change the machine type, this adjusts the number of GPUs that are attached to the VM.
Verify that all of your critical applications are stopped on the VM, and then create a POST command to stop the VM so it can move to a host system where GPUs are available.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/stop
After the VM stops, create a POST request to modify the machine type.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/setMachineType { machineType: "zones/ZONE/machineTypes/MACHINE_TYPE" }
Start the VM.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/start
Replace the following:
PROJECT_ID
: your project ID.VM_NAME
: the name of the VM that you want to add GPUs to.ZONE
: the zone where the VM is located. This zone must support GPUs.MACHINE_TYPE
: the machine type that you want to use. It must be one of the following:
--machine-type=g2-custom-4-19456
.a2-megagpu-16g
A2 Standard machine types. When using Windows operating systems, choose a different A2 Standard machine type.format fs=ntfs label=tmpfs
.pd-standard
) isn't supported on instances that use the G2 machine type. For supported disk types, see Supported disk types for G2.525.60.13
or later. For more information, review the Container-Optimized OS release notes.sudo cos-extensions install gpu -- -version=525.60.13
.This section covers how to add, modify, or remove GPUs from a N1-general purpose machine.
In summary, the process to add, modify, or remove GPUs from an existing VM is as follows:
Add, modify, or remove the GPUs.
If your VM didn't have GPUs attached before, you need to complete the following steps:
When a GPU is added to a VM, the order of the network interface can change.
Most public images on Compute Engine don't have persistent network interface names and adjust to the new order.
However, if you are using either SLES or a custom image, you must update the system setting to prevent the network interface from persisting. To prevent the network interface from persisting, run the following command on your VM:
rm /etc/udev/rules.d/70-persistent-net.rulesAdd GPUs or modify GPU type on existing VMs
This section covers how to add GPUs, or modify the GPU type on an existing N1 general-purpose VMs. This procedure supports the following GPU types:
NVIDIA GPUs:
nvidia-tesla-t4
nvidia-tesla-p4
nvidia-tesla-p100
nvidia-tesla-v100
NVIDIA RTX Virtual Workstation (vWS) (formerly known as NVIDIA GRID):
nvidia-tesla-t4-vws
nvidia-tesla-p4-vws
NVIDIA P100 Virtual Workstation: nvidia-tesla-p100-vws
For these virtual workstations, an NVIDIA RTX Virtual Workstation (vWS) license is automatically added to your instance.
To add GPUs or modify the GPU type, complete the following steps.
Verify that all of your critical applications are stopped on the VM.
In the Google Cloud console, go to the VM instances page to see your list of VMs.
Click the name of the VM that you want to update. The Details page opens.
Complete the following steps from the Details page.
If the VM is running, click stop Stop. If there is no Stop option, click more_vert More actions > stop Stop.
Click edit Edit.
In the Machine configuration section, select the GPUs machine family, and then do the following:
In the GPU type list, select or switch to any of the GPU types supported on N1 VMs.
In the Number of GPUs list, select the number of GPUs.
If your GPU model supports NVIDIA RTX Virtual Workstations (vWS) for graphics workloads, and you plan on running graphics-intensive workloads on this VM, select Enable Virtual Workstation (NVIDIA GRID).
If your VM didn't have GPUs attached before, complete the following:
If the VM has a shared-core machine type, you must change the machine type. In the Machine type list, select one of the preset N1 machine types. Alternatively, you can also specify custom machine type settings.
In the Management section, complete the following:
In the On host maintenance list, select Terminate VM instance. VMs with attached GPUs can't live migrate. See Handle GPU host events.
In the Automatic restart list, select On.
To apply your changes, click Save.
To restart the VM, click Start/Resume.
You can add or modify GPUs on your VM by stopping the VM and changing your VM's configuration through the API.
Verify that all of your critical applications are stopped on the VM and then create a POST command to stop the VM so it can move to a host system where GPUs are available.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/stop
If your VM didn't have GPUs attached before, complete the following steps:
Identify the GPU type that you want to add to your VM. You can submit a GET
request to list the GPU types that are available to your project in a specific zone.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/acceleratorTypes
If the VM has a shared-core machine type, you must change the machine type to have one or more vCPUs. You cannot add accelerators to VMs with shared-core machine types.
Create a POST command to set the scheduling options for the VM.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/setScheduling { "onHostMaintenance": "TERMINATE", "automaticRestart": true }
Create a POST request to add or modify the GPUs that are attached to your VM.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/setMachineResources { "guestAccelerators": [ { "acceleratorCount": ACCELERATOR_COUNT, "acceleratorType": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/acceleratorTypes/ACCELERATOR_TYPE" } ] }
Start the VM.
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME/start
Replace the following:
PROJECT_ID
: your project ID.VM_NAME
: the name of the VM that you want to add GPUs to.ZONE
: the zone where the VM is located.ACCELERATOR_COUNT
: the number of GPUs that you want attached to your VM. For a list of GPU limits based on the machine type of your VM, see GPUs on Compute Engine.ACCELERATOR_TYPE
: the GPU model that you want to attach or switch to. If you plan on running graphics-intensive workloads on this VM, use one of the virtual workstation models.
Choose one of the following values:
NVIDIA GPUs:
nvidia-tesla-t4
nvidia-tesla-p4
nvidia-tesla-p100
nvidia-tesla-v100
NVIDIA RTX Virtual Workstation (vWS) (formerly known as NVIDIA GRID):
nvidia-tesla-t4-vws
nvidia-tesla-p4-vws
nvidia-tesla-p100-vws
For these virtual workstations, an NVIDIA RTX Virtual Workstation (vWS) license is automatically added to your instance.
To install the drivers, choose one of the following options:
This section covers how to remove the following GPU types from an existing N1 general-purpose VM.
NVIDIA GPUs:
nvidia-tesla-t4
nvidia-tesla-p4
nvidia-tesla-p100
nvidia-tesla-v100
NVIDIA RTX Virtual Workstation (vWS) (formerly known as NVIDIA GRID):
nvidia-tesla-t4-vws
nvidia-tesla-p4-vws
NVIDIA P100 Virtual Workstation: nvidia-tesla-p100-vws
For these virtual workstations, an NVIDIA RTX Virtual Workstation (vWS) license is automatically added to your instance.
You can use the Google Cloud console to remove GPUs from an existing VM. To remove GPUs, complete the following steps:
Verify that all of your critical applications are stopped on the VM.
In the Google Cloud console, go to the VM instances page to see your list of VMs.
Click the name of the VM that you want to remove GPUs from. The Details page opens.
Complete the following steps from the Details page.
If the VM is running, click stop Stop to stop the VM. If there is no Stop option, click more_vert More actions > stop Stop.
On the toolbar, click edit Edit.
In the Machine configuration section, select the General purpose machine family, and then do the following:
To view attached GPUs, expand Advanced configurations.
In the GPUs section, remove GPUs using one of the following options:
To remove some GPUs, in the Number of GPUs list, select a new number.
To remove all GPUs, click delete Delete GPU.
Optional: Modify the VM host maintenance policy setting. VMs with GPUs must have the host maintenance policy set to Terminate VM instance. But if you removed all GPUs, you have the option to live migrate this VM during host maintenance. For more information, see Set VM host maintenance policy.
To apply your changes, click Save.
To restart the VM, click Start/Resume.
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 2025-08-11 UTC.
[[["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 2025-08-11 UTC."],[[["Compute Engine allows the addition of GPUs to virtual machines (VMs) to accelerate workloads like machine learning and data processing, utilizing accelerator-optimized (A3, A2, G2) or N1 general-purpose machine families."],["Accelerator-optimized VMs, including A3, A2, and G2 types, have specific NVIDIA GPU models attached, such as H100, A100, and L4, with varying capabilities and options for modifying GPU counts or machine types within their respective families."],["Modifying GPU counts on A2 Standard and G2 VMs can be done via the Google Cloud console or REST API by stopping the VM and adjusting the machine type or GPU number, but removing GPUs from accelerator-optimized machines often requires creating a new VM or changing to a different machine family."],["N1 general-purpose VMs can have various NVIDIA GPU models added, modified, or removed, requiring the VM to be stopped, potentially needing a machine type change if it was shared-core, and adjustment of host maintenance settings to \"Terminate VM instance\" due to GPU limitations."],["Before modifying or adding GPUs, it is important to verify that critical applications are stopped, to install the correct GPU drivers after any changes, and to be aware of the specific limitations and requirements for different machine types and GPU models, including operating system compatibility, discounts, and supported features."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4