System Metrics

The prov4ml.log_system_metrics function logs critical system performance metrics during machine learning experiments. The information logged is related to the time between the last call to the function and the current call.

prov4ml.log_system_metrics(
    context: Context,
    step: Optional[int] = None,
)
ParameterTypeDescription
contextprov4ml.ContextRequired. Context of the metric
stepintOptional. Step of the metric

This function logs the following system metrics:

ParameterDescriptionUnit
cpu_usage_pctCPU utilization percentage%
cpu_powerPower consumed by the CPUWatts (W)
cpu_energyEnergy consumed by the CPU over the logging intervalJoules (J)
ram_usage_pctPercentage of total RAM used%
ram_usage_gbAmount of RAM used in gigabytesGigabytes (GB)
ram_powerPower consumed by the system RAMWatts (W)
ram_energyEnergy consumed by RAM over the logging intervalJoules (J)
disk_usage_gbAmount of disk space used in gigabytesGigabytes (GB)
disk_usage_pctPercentage of total disk space used%
gpu_usage_pctGPU compute utilization percentage%
gpu_powerPower consumed by the GPUWatts (W)
gpu_energyEnergy consumed by the GPU over the logging intervalJoules (J)
gpu_memory_usage_gbAmount of GPU VRAM used in gigabytesGigabytes (GB)
gpu_memory_usage_pctPercentage of GPU VRAM used%
gpu_memory_powerPower consumed by the GPU VRAM moduleWatts (W)
gpu_temperature_cTemperature of the GPU coreDegrees Celsius (°C)

FLOPs per Epoch

The log_flops_per_epoch function logs the number of floating-point operations (FLOPs) performed per epoch for a given model and dataset.

prov4ml.log_flops_per_epoch(
    label: str, 
    model: Union[torch.nn.Module, Any],
    dataset: Union[torch.utils.data.Dataset, torch.utils.data.DataLoader, torch.utils.data.Subset], 
    context: Context, 
    step: Optional[int] = None
):
ParameterTypeDescription
labelstringRequired. Label of the FLOPs
modelUnion[torch.nn.Module, Any]Required. Model used for the FLOPs calculation
datasetstringRequired. Dataset used for the FLOPs calculation
contextprov4ml.ContextRequired. Context of the metric
stepintOptional. Step of the metric

FLOPs per Batch

The log_flops_per_batch function logs the number of floating-point operations (FLOPs) performed per batch for a given model and batch of data.

prov4ml.log_flops_per_batch(
    label: str, 
    model: Union[torch.nn.Module, Any],
    batch: Any, 
    context: Context, 
    step: Optional[int] = None, 
):
ParameterTypeDescription
labelstringRequired. Label of the FLOPs
modelUnion[torch.nn.Module, Any]Required. Model used for the FLOPs calculation
batchAnyRequired. Batch of data used for the FLOPs calculation
contextprov4ml.ContextRequired. Context of the metric
stepintOptional. Step of the metric