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 above
index 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.pciDeviceIdandpci.pciSubSystemIdare not availableGPU_UTILIZATION:gpu_utilizationandmemory_utilizationare not availablePOWER_LIMIT:power_limitis not availablePOWER_USAGE:power_usageis not availableTEMPERATURE:temperatureis not available
Example:
Example
Constructors
GPUResourceMonitor
Construct a new GPUResourceMonitor object.
This constructor creates a new GPUResourceMonitor object.
Parameters
The metric flags (default: GPU_DEVICE_ID)
Destructor
~GPUResourceMonitor
Methods
init
Initialize the GPU resource monitor.
close
Close handle of the GPU resource monitor.
This function closes the handle of the opened NVML and CUDA Runtime libraries if they are open.
metric_flags
Mutable
Const
Set metric flags.
This function sets the metric flags.
Parameters
The metric flags
update
Update the GPU information and cache it
Update all GPU information and cache it
Update the GPU information
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.
gpu_info
Get the GPU information
Get all GPU information
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.
num_gpus
Get the number of GPUs.
Returns: The number of GPUs.
is_integrated_gpu
Check whether the GPU is integrated (iGPU).
Returns: True if the GPU is integrated (iGPU), false otherwise.