mednet.utils.resources#
Tools for interacting with the running computer or GPU.
Module Attributes
The number of bytes in a gigabyte. |
Functions
|
Aggregate monitored data to average/max each entry. |
Return static CPU information about the current system. |
|
Return GPU (static) information using nvidia-smi. |
|
Return GPU (static) information using /usr/bin/powermetrics. |
Classes
|
An external, non-blocking CPU/GPU resource monitor. |
- mednet.utils.resources.GB = 1073741824.0#
The number of bytes in a gigabyte.
- mednet.utils.resources.cuda_constants()[source]#
Return GPU (static) information using nvidia-smi.
Check
_run_nvidia_smi()for operational details if necessary.- Returns:
If
nvidia-smiis not available, returnsNone, otherwise, we return a dictionary containing the followingnvidia-smiquery information, in this order:- Return type:
- mednet.utils.resources.mps_constants()[source]#
Return GPU (static) information using /usr/bin/powermetrics.
- Returns:
If
nvidia-smiis not available, returnsNone, otherwise, we return a dictionary containing the followingnvidia-smiquery information, in this order:- Return type:
- mednet.utils.resources.cpu_constants()[source]#
Return static CPU information about the current system.
- class mednet.utils.resources.ResourceMonitor(interval, device_type, main_pid)[source]#
Bases:
objectAn external, non-blocking CPU/GPU resource monitor.
- Parameters:
interval (
int|float) – Number of seconds to wait between each measurement (maybe a floating point number as accepted bytime.sleep()).device_type (
Literal['cpu','cuda','mps']) – String representation of one of the supported pytorch device types triggering the correct readout of resource usage.main_pid (
int) – The main process identifier to monitor.
- mednet.utils.resources.aggregate(data, start=0, end=None)[source]#
Aggregate monitored data to average/max each entry.
- Parameters:
- Returns:
A collapsed representation of the input list with the common keys found in all dictionaries and averages (or maximum values) of measures found across similar keys.
- Return type: