9.18.9.6. Assigning a vGPU to a VM by using the CLI
Assign mediated devices such as virtual GPUs (vGPUs) to virtual machines (VMs).
Prerequisites
-
The mediated device is configured in the
HyperConvergedcustom resource. - The virtual machine (VM) is stopped.
Procedure
Assign the mediated device to a VM by editing the
spec.domain.devices.gpusstanza of theVirtualMachinemanifest.Example virtual machine manifest:
apiVersion: kubevirt.io/v1 kind: VirtualMachine spec: domain: devices: gpus: - deviceName: nvidia.com/TU104GL_Tesla_T4 name: gpu1 - deviceName: nvidia.com/GRID_T4-2Q name: gpu2-
spec.template.spec.domain.devices.gpus.deviceNamespecifies the resource name associated with the mediated device. -
spec.template.spec.domain.devices.gpus.namespecifies a name to identify the device on the VM.
-
Verification
To verify that the device is available from the virtual machine, run the following command, substituting
<device_name>with thedeviceNamevalue from theVirtualMachinemanifest:$ lspci -nnk | grep <device_name>