From Open-IOV
Jump to navigation Jump to search

This page makes use of terms that are defined in the OpenMdev Glossary. If you're curious what a given term means you can check there for a definition.

This page will be used to document the Mdev-GPU API as well as provide an overview of the internals of the Mdev-GPU package.

Mdev-GPU's source code can be found here.

Module docs can be found here.

An absence of critical technical documentation has historically slowed growth and adoption of developer ecosystems for GPU virtualization.

This CC-BY-4.0 licensed content can either be used with attribution, or used as inspiration for new documentation, created by GPU vendors for public commercial distribution as developer documentation.

Where possible, this documentation will clearly label dates and versions of observed-but-not-guaranteed behaviour vs. vendor-documented stable interfaces/behaviour with guarantees of forward or backward compatibility.


Compiling Mdev-GPU from source is very simple however it can take a long time to complete (10 minutes for existing sources).

If you'd like to compile Mdev-GPU yourself you can do so by cloning the repo and running the following two commands from within the repository directory:

curl -sSL | sh

stack install

These commands will generate all binaries provided by Mdev-GPU under the path ~/.local/bin/.

If you would prefer not to wait for the program to compile you can find pre-compiled x86_64 binaries under the Releases section of the repository on GitHub.


The binaries compiled on your local machine by Stack in the ~/.local/bin/ path or downloaded from Releases on GitHub should be copied to /usr/bin/. This can be accomplished both via install script (currently testing in LibVF.IO) or via management layer-agnostic package.

Mdev-GPU Configuration

The Mdev-GPU repository provides Systemd service and example configurations for Mdev-CLI in the /etc/ folder. On installation the directories & files contained in the repository's /etc/ folder should be copied to the absolute path /etc/ on the user's computer.


GVM/Mdev-GPU exposes several of it's functions as Systemd services.

As of the release the following Systemd services are available:

  • mdev-post.service

As the name would suggest mdev-post.service posts the GPU(s) in a state where they are ready to be virtualized. When the service is invoked the mdev-cli util registers Mdev callbacks and supported mediated device (Mdev) types with the Mediated Core according to the user's specified configuration at /etc/gvm/mdev-gpu/generate-vgpu-types.yaml. If you'd like to place your configuration file elsewhere and still have your configuration invoked on boot you can edit the systemd service ExecStart= line to specify an alternative path.


Configuration for Mdev-GPU can be found in the path /etc/gvm/mdev-gpu/. This path will by default contain several vendor-specific folders which may include configuration examples for various devices/architectures as well as the file generate-vgpu-types.yaml which you can configure to specify your desired Virtual GPU (vGPU) / VFIO-Mdev topologies as they are presented in the sysfsdev mdev_bus path and as seen by tools such as mdevctl. Once you have configured the available types your liking you can refresh the supported types registered with the Mediated Core by rebooting your machine or reloading the vendor driver kernel module then restarting mdev-post.service or by invoking mdev-cli.

The available yaml properties which may be specified in /etc/gvm/mdev-gpu/generate-vgpu-types.yaml are shown below. Note that fields with the [required] tag must be specified in the yaml file whereas fields with the [optional] tag may be omitted from configuration if you would prefer to rely upon default parameters instead.



num refers to the Mediated Device (Mdev) type number. This value specifies the profile's numerical identifier in the sysfsdev mdev_bus path.



The vGPU (Virtual GPU) PCI Device ID which should be presented to the guest.



The pGPU (Physical GPU) PCI Device ID which should be presented to the host.



The GPU name presented to the guest.



The class of GPU to use.

available strings:





maxInstances refers to the maximum number of instances available of any given Mediated Device (Mdev) profile. This number can be configured arbitrarily however it should ideally not be set to a value which allows for fbLen/fbRes values that allow a number of Mdev devices to be created which would exceed your device's available VRAM.



virtDisplay controls the topologies of virtual displays. virtDisplay exposes the following user configurable properties:



Number of heads [virtual monitors] available for each Mediated Device (Mdev).



Maximum width of the mediated display.



Maximum height of the mediated display.



Frame rate limiter for the mediated display.



Do we enable frame rate limiting or not?



ecc refers to if error correcting memory should be used.



fbLen is the framebuffer length (in megabytes).



fbRes is the framebuffer reserved by the hypervisor (in megabytes). In most circumstances this value should scale to around 1/7th the size of your chosen fbLen value.



Mappable video size in MBs, 24 by default.



Percentage we use the NvEnc hardware.



bar1Len refers to the size of the Base Address Registers for BAR1 (MSI) as presented by the VFIO File Descriptor.