These instructions only cover Intel GPUs that are compatible with vfio-mdev (5th to 10th generation). Since generation 11th, vfio-mdev has been superseded by SR-IOV.
GPUs compatible with Virtual Function I/O Mediated devices (vfio-mdev) can be split into multiple virtual GPUs (vGPUs).
Then, these vGPUs can be assigned to virtual machines or containers.
Contrary to paravirtualized GPUs (e.g. virtio-gpu), vGPUs can use the same driver as their parent GPU (e.g. a guest compatible with an Intel GPUs will be able to leverage an Intel-based vGPUs)
Some computers allow you to modify the system memory allocated or shared with the integrated GPU, which may allow you to create more vGPUs.
For Intel integrated graphics cards only; rarely available on laptops computers.
Before the host operating system boots up, you need to enter the BIOS/UEFI and to look for a setting called GPU aperture size, or GPU shared memory.
Use the highest possible value.
System memory will be reserved for the GPU, so make sure you have enough system memory to accomodate both the GPU and your operating system.
List available GPUs using the mdevctl
software:
mdevctl types
0000:00:02.0
i915-GVTg_V5_1
Available instances: 1
Device API: vfio-pci
Description: low_gm_size: 512MB, high_gm_size: 2048MB, fence: 4, resolution: 1920x1200, weight: 16
i915-GVTg_V5_2
Available instances: 2
Device API: vfio-pci
Description: low_gm_size: 256MB, high_gm_size: 1024MB, fence: 4, resolution: 1920x1200, weight: 8
i915-GVTg_V5_4
Available instances: 5
Device API: vfio-pci
Description: low_gm_size: 128MB, high_gm_size: 512MB, fence: 4, resolution: 1920x1200, weight: 4
i915-GVTg_V5_8
Available instances: 7
Device API: vfio-pci
Description: low_gm_size: 64MB, high_gm_size: 384MB, fence: 4, resolution: 1024x768, weight: 2
Increasing the memory allocated to the GPU in the BIOS/EFI may increase the number and kind of available instances.
In this case, the i915-GVTg_V5_4
kind seems to offer the best trade-offs between the available resolution and the number of available instances.
uuidgen
7686131b-b229-4768-a02c-35d1dbed7c66
i915-GVTg_V5_4
using the previously generated UUIDsudo mdevctl start -u 7686131b-b229-4768-a02c-35d1dbed7c66 -p 0000:00:02.0 --type i915-GVTg_V5_4
sudo mdevctl define -u 7686131b-b229-4768-a02c-35d1dbed7c66
sudo mdevctl modify -u 7686131b-b229-4768-a02c-35d1dbed7c66 --auto
mdevctl list -d
7686131b-b229-4768-a02c-35d1dbed7c66 0000:00:02.0 i915-GVTg_V5_4 auto (active)
uuid
matches the previously generated UUID.<domain type="kvm">
[...]
<device>
[...]
<hostdev mode="subsystem" type="mdev" managed="no" model="vfio-pci" display="on" ramfb="on">
<source>
<address uuid="7686131b-b229-4768-a02c-35d1dbed7c66"/>
</source>
<address type="pci" domain="0x0000" bus="0x09" slot="0x00" function="0x0"/>
</hostdev>
[...]
</device>
[...]
</domain>
Notice that the RAMFB is set to on, which activates Drect Memory Access Buffers (DMA-BUFs), making the output of a virtual monitor available before the guest operating system takes over.
virtio-gpu
and set the last one to the none
.<domain type="kvm">
[...]
<device>
[...]
<video>
<model type="none"/>
</video>
[...]
</device>
[...]
</domain>
To-do
Increasing the memory allocated to the GPU (a.k.a. the GPU aperture size) may increase the number of available instances.
Some computers allow you to modify the memory allocated or shared with the integrated GPU, which may allow you to create more vGPUs.
Before the host operating system boots up, enter the BIOS/UEFI and look for a setting called GPU aperture size, or GPU shared memory.
Use the highest possible value.
The memory will be reserved to the GPU, so make sure you have enough leftover memory to accomodate both the GPU and your operating system.