Energy
Energy modules for benchmarking
compute_energy_multi
def compute_energy_multi(
model:torch.nn.Module, # model to benchmark
sample:torch.Tensor, # input tensor (with batch dimension)
devices:Sequence[str | torch.device] | None=None, # devices to benchmark (default: cpu + cuda)
kwargs:VAR_KEYWORD
)->dict[str, EnergyMetrics]:
Measure energy on multiple devices.
compute_energy
def compute_energy(
model:torch.nn.Module, # model to benchmark
sample:torch.Tensor, # input tensor (with batch dimension)
device:str | torch.device='cpu', # device to run on
warmup:int=20, # warmup iterations
steps:int=100, # measurement iterations
offline:bool=True, # use offline emissions tracker
country_iso:str | None=None, # country ISO code for carbon intensity
measure_secs:int=1, # power sampling interval
)->EnergyMetrics:
Measure power consumption and carbon footprint using codecarbon.
EnergyMetrics
def EnergyMetrics(
mean_watts:float, energy_wh:float, co2_eq_g:float
)->None:
Energy consumption and carbon footprint metrics.