How to Install NVIDIA Drivers in GCP VMs

**NOTE: GPU VMs cannot migrate in GCP. Therefore, if you create a VM that needs GPU in GCP, you need to change the On Host Maintenance from Migrate VM Instance to Terminate VM Instance

Just know that if GCP ever performs maintenance in the host where this VM is located, the VM will terminate. So, there will be a down time.

If you need to add a GPU, that will be located under CPU PLATFORM AND GPU

Expand and add the GPU needed.

  1. Install the CUDA Drivers for Tesla T4 from GCP Website https://cloud.google.com/compute/docs/gpus/install-drivers-gpu#verify-windows

  2. Once installed install the GRID drivers from the GCP Site https://cloud.google.com/compute/docs/gpus/grid-drivers-table Use the drivers that match the version of OS and the version of your CUDA drivers.

  3. Once that is installed, you can verify by running the command:

Install Using the Driver Script.

This installation script can be used on VMs that have secure boot enabled.

  • For Windows VMs that use a G2 machine series, this script installs only the NVIDIA driver.

  • For other machine types, the script installs the NVIDIA driver and CUDA toolkit.

Open a PowerShell terminal as an administrator, then complete the following steps:

  1. If you are using Windows Server 2016, set the Transport Layer Security (TLS) version to 1.2.

    [Net.ServicePointManager]::SecurityProtocol = 'Tls12'
  2. Download the script.

    Invoke-WebRequest https://github.com/GoogleCloudPlatform/compute-gpu-installation/raw/main/windows/install_gpu_driver.ps1 -OutFile C:\install_gpu_driver.ps1
  3. Run the script.

    C:\install_gpu_driver.ps1

    The script takes some time to run. No command prompts are given during the installation process. Once the script exits, the driver is installed.

    This script installs the drivers in the following default location on your VM: C:\Program Files\NVIDIA Corporation\.

  4. Verify the installation. See Verifying the GPU driver install.

"C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe"

Your result should look like this:

If WDDM is not enabled, you can enable it by getting the GUID for the Driver, go to:

C:\Program Files\NVIDIA Corporation\NVSMI>

And run this command:

nvidia-smi -q

Your result should look like this, and you want to copy the GUID

If TCC is enabled and you need to enable WDDM, then run this command.

nvidia-smi -g GPU-c3a82135-86d1-d8c5-b480-7ac94419489b -dm 0

Notice the last part of the command.

0 = WDDM Driver Model

1 = TCC Driver Model

Note: WDDM is needed if the software requires OpenGL. TCC driver model does not support OpenGL