holoscan::GPUResourceMonitor
holoscan::GPUResourceMonitor
holoscan::GPUResourceMonitor
GPUResourceMonitor class.
This class is responsible for monitoring the GPU resources. It provides the information about the GPU resources (through holoscan::GPUInfo) to the SystemResourceManager class.
The following holoscan::GPUMetricFlag flags are supported:
DEFAULT: Default GPU metrics (GPU_DEVICE_ID)GPU_DEVICE_ID: GPU device ID (name, pci, serial, uuid)GPU_UTILIZATION: GPU utilization (gpu_utilization, memory_utilization)MEMORY_USAGE: GPU memory usage (memory_total, memory_free, memory_used, memory_usage)POWER_LIMIT: GPU power limit (power_limit)POWER_USAGE: GPU power usage (power_usage)TEMPERATURE: GPU temperature (temperature)ALL: All GPU metrics aboveindex information is always available.
This uses the NVML library to get the GPU information. If NVML library is not available (in case of iGPU), this class uses the CUDA Runtime API to get the GPU information.
The following information is not available when using the CUDA Runtime API:
GPU_DEVICE_ID: pci.pciDeviceId and pci.pciSubSystemId are not availableGPU_UTILIZATION: gpu_utilization and memory_utilization are not availablePOWER_LIMIT: power_limit is not availablePOWER_USAGE: power_usage is not availableTEMPERATURE: temperature is not availableExample:
Construct a new GPUResourceMonitor object.
This constructor creates a new GPUResourceMonitor object.
Parameters
The metric flags (default: GPU_DEVICE_ID)
Initialize the GPU resource monitor.
Close handle of the GPU resource monitor.
This function closes the handle of the opened NVML and CUDA Runtime libraries if they are open.
Set metric flags.
This function sets the metric flags.
Parameters
The metric flags
Update the GPU information and cache it.
This function updates information for the GPU with the given index based on the given metric flags and returns the GPU information. If the metric flags are not provided, the existing metric flags are used. It also caches the GPU information.
Returns: The GPU information.
Parameters
The GPU index.
The metric flags.
Get the GPU information.
This method returns the GPU information based on the given index.
If the metric flags are provided, it returns the vector of GPU information based on the given metric flags. If the metric flags are not provided, it returns the cached GPU information.
Returns: The GPU information.
Parameters
The GPU index.
The metric flags.
Get the number of GPUs.
Returns: The number of GPUs.
Check whether the GPU is integrated (iGPU).
Returns: True if the GPU is integrated (iGPU), false otherwise.