// Module included in the following assemblies:
//
// * virt/virtual_machines/advanced_vm_management/virt-configuring-virtual-gpus.adoc

:_mod-docs-content-type: PROCEDURE
[id="virt-assigning-mdev-vm-cli_{context}"]
= Assigning a vGPU to a VM by using the CLI

[role="_abstract"]
Assign mediated devices such as virtual GPUs (vGPUs) to virtual machines (VMs).

.Prerequisites

* The mediated device is configured in the `HyperConverged` custom resource.
* The virtual machine (VM) is stopped.

.Procedure

* Assign the mediated device to a VM by editing the `spec.domain.devices.gpus` stanza of the `VirtualMachine` manifest.
+
Example virtual machine manifest:
+
[source,yaml]
----
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.deviceName` specifies the resource name associated with the mediated device.
** `spec.template.spec.domain.devices.gpus.name` specifies 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 the `deviceName` value from the `VirtualMachine` manifest:
+
[source,terminal]
----
$ lspci -nnk | grep <device_name>
----
