Managing vGPUs from a hypervisor by using NVML#
NVIDIA vGPU software supports monitoring and control of physical GPUs and virtual GPUs that are running on virtualization hosts. NVML includes functions that are specific to managing vGPUs on NVIDIA vGPU software virtualization hosts. These functions are defined in the nvml_grid.h header file.
Note
NVIDIA vGPU software does not support the management of pass-through GPUs from a hypervisor. NVIDIA vGPU software supports the management of pass-through GPUs only from within the guest VM that is using them.
Determining whether a GPU supports hosting of vGPUs#
If called on platforms or GPUs that do not support NVIDIA vGPU, functions that are specific to managing vGPUs return one of the following errors:
NVML_ERROR_NOT_SUPPORTEDNVML_ERROR_INVALID_ARGUMENT
To determine whether a GPU supports hosting of vGPUs, call the nvmlDeviceGetVirtualizationMode() function.
A vGPU-capable device reports its virtualization mode as NVML_GPU_VIRTUALIZATION_MODE_HOST_VGPU.
Discovering the vGPU capabilities of a physical GPU#
To discover the vGPU capabilities of a physical GPU, call the functions in the following table.
Function |
Purpose |
|---|---|
|
Determine the virtualization mode of a GPU. GPUs capable of hosting virtual GPUs report their virtualization mode as |
|
Return a list of vGPU type IDs that are supported by a GPU. |
|
Return a list of vGPU type IDs that can currently be created on a GPU. The result reflects the number and type of vGPUs that are already running on the GPU.
|
|
Return a list of handles for vGPUs currently running on a GPU. |
|
Return a vGPU metadata structure for the physical GPU. |
|
Determine whether the requested vGPU capability is supported by the specified physical GPU. |
Getting the properties of a vGPU type#
To get the properties of a vGPU type, call the functions in the following table.
Function |
Purpose |
|---|---|
|
Read the class of a vGPU type (for example, Quadro, or NVS) |
|
Read the name of a vGPU type (for example, GRID M60-0Q) |
|
Read PCI device ID of a vGPU type (vendor/device/subvendor/subsystem) |
|
Read the frame buffer size of a vGPU type |
|
Read the number of display heads supported by a vGPU type |
|
Read the maximum resolution of a vGPU type’s supported display head |
|
Read license information required to operate a vGPU type |
|
Read the static frame limit for a vGPU type |
|
Read the maximum number of vGPU instances that can be created on a GPU |
|
Read the corresponding GPU instance profile ID of a vGPU type. Because NVIDIA vGPU software supports only GPUs that do not support MIG, this function returns |
|
Determine whether the vGPU type supports peer-to-peer CUDA transfers over NVLink or GPUDirect® technology. |
Getting the properties of a vGPU instance#
To get the properties of a vGPU instance, call the functions in the following table.
Function |
Purpose |
|---|---|
|
Read the ID of the VM currently associated with a vGPU instance |
|
Read a vGPU instance’s UUID |
|
Read a vGPU instance’s virtual function I/O (VFIO) mediated device ( |
|
Read the guest driver version currently loaded on a vGPU instance |
|
Read a vGPU instance’s current frame buffer usage |
|
Read the following frame buffer capture (FBC) statistics for a vGPU instance:
|
|
For each active FBC session on a vGPU instance, read the following statistics:
|
|
Read a vGPU instance’s current license status (licensed or unlicensed) |
|
Read the vGPU type ID of a vGPU instance |
|
Read a vGPU instance’s frame rate limit |
|
Read the following encoder statistics for a vGPU instance:
|
|
For each active encoder session on a vGPU instance, read the following statistics:
|
|
Read a vGPU instance’s usage of the following resources as a percentage of the physical GPU’s capacity:
|
|
For each process running on a vGPU instance, read the process ID and usage by the process of the following resources as a percentage of the physical GPU’s capacity:
|
|
Return a structure containing information about whether a vGPU or a physical GPU supports NVIDIA vGPU software licensing and, if so, additional licensing information such as:
|
|
Read the accounting mode of the vGPU instance |
|
Read the maximum number of processes that can be queried and the current list of process IDs |
|
For each process ID returned by
|
|
Return compatibility information about a vGPU and a physical GPU, such as:
|
|
Return a vGPU metadata structure for a vGPU and its associated VM |
|
Determine whether the requested vGPU driver capability is supported by the Virtual GPU manager. |
Building an NVML-enabled application for a vGPU host#
Functions that are specific to vGPUs are defined in the header file nvml_grid.h.
To build an NVML-enabled application for a vGPU host, ensure that you include nvml_grid.h in addition to nvml.h:
#include <nvml.h>
#include <nvml_grid.h>
For more information, refer to the sample code that is included in the SDK.