How to Pass Through a GPU in VMware ESXi

GPU passthrough maps a physical GPU to a VM. Let's learn how to set up GPU passthrough with a step-by-step tutorial for VMware environments.

Introduction

In a VMware environment, GPU passthrough maps a VM to a Peripheral Component Interconnect (PCI) device physically installed in the host server. To make a GPU available to a VM, one or more PCI-based GPUs must be installed in the host, and VMware ESXi must be able to recognize the presence of the GPU devices.

GPU passthrough maps a physical GPU to a VM. The VM's operating system can then use the GPU just as it would if it were running on a physical machine equipped with a hardware GPU. Here’s a step-by-step guide on how to enable GPU passthrough:

Requirements

GPU passthrough requires certain conditions to be met for successful implementation. The following are the main conditions:

Hardware Support: Ensure your CPU and motherboard support Intel VT-d or AMD IOMMU, as well as a dedicated GPU.

Virtualization software: Virtualization platforms that support GPU passthrough: e.g. KVM, Xen, VMware ESXi, etc. Ensure that the hypervisor used is capable of supporting GPU passthrough functionality.

Separate GPU for Host and VM: GPU pass-through requires that the GPU in the physical host can be used exclusively, usually requiring a dedicated GPU.

How to implement GPU passthrough for VMware EXSi?

Step 1: Create the VM

1.1 Download the ISO to your local computer. Upload the ISO needed to install VM in “Datastore browser”.

Upload iso
Upload iso 2

1.2 Click on "Create / Register VM".

Create/Register VM

1.3 Please name the VM. The appropriate OS family and OS version need to be selected.

Select a name and guest os

1.4 Select the path to the ISO you just uploaded.

Select storage path

1.5 Select the ISO you uploaded. CPU, memory and disk size can be set by yourself.

New vm customize settings

1.6 Power on the VM, open the VM console, and select the “EFI VMware Virtual SATA CDROM Drive (0.0)” option when installing the system. Then install the system.

Boot Manager
Install Windows

Step 2: Turn on GPU passthrough for the selected device

2.1 After logging into the ESXi web client, expand the list of hosts and select the Manage node. Then select the Hardware tab at the top of the screen to view a list of hardware devices installed in the host.

2.2 Next, check the checkboxes corresponding to the devices for which you want to enable GPU passthrough, and then click the Toggle Passthrough button, and the Passthrough column for the selected devices is set to Disabled.

2.3 If you see an error message stating that passthrough cannot be enabled until you reboot the host computer, you need to try rebooting the host computer and then click the Toggle Passthrough button.

Toggle Passthrough in ESXi 8.0
Toggle Passthrough 2 in ESXi 8.0

Step 3: Assigning GPU hardware to a VM

3.1 The next step is to assign the GPU hardware to the VM. to do this, select the Virtual Machines node of the console and then select the VM in which you plan to use the GPU.

3.2 Click the Edit button to display the Edit Settings window for the VM. Click Add Add Other Device, and then select PCI Device. select your GPU from the list of available PCI devices, and then select the option to add a PCI device.

Edit settings Add devices in ESXi 8.0
Edit settings Add devices 2 in ESXi 8.0

3.3 In addition to selecting a PCI device. you need to set up a memory reservation for the device. otherwise the VM will not start. click the Reserve All Memory button to create the necessary memory reservation.

Edit settings Memory in ESXi 8.0

Step 4: Configuration Parameters to Initialize the GPU.

Next, select the VM Options tab of the dialog box, expand the Advanced section, and click the Edit Configuration button to display the Configuration Parameters dialog box.

Click the Add Parameter button and create a new parameter called hypervisor.cpuid.v0. Set its value to FALSE, making sure to use all capital letters.

Edit settings VM Options in ESXi 8.0
Edit Configuration in ESXi 8.0
Configuration Parameters in ESXi 8.0

Step 5: Install the graphics card driver on the VM.

Through Nvidia's official website, simply download and install the appropriate GPU driver in the virtual machine.

ESXi Host Client