carbonai.PowerMeter.start_measure¶
- PowerMeter.start_measure(package, algorithm, step='other', data_type='', data_shape='', algorithm_params='', comments='')¶
Starts mesuring the power consumption of a given sample of code
- Parameters
- packagestr
A string describing the package used by this function (e.g. sklearn, Pytorch, …)
- algorithmstr
A string describing the algorithm used in the function monitored (e.g. RandomForestClassifier, ResNet121, …)
- step{‘inference’, ‘training’, ‘other’, ‘test’, ‘run’, ‘preprocessing’}, optional
A string to provide useful information on the current stage of the algorithm
- data_type{‘tabular’, ‘image’, ‘text’, ‘time series’, ‘other’}, optional
A string describing the type of data used for training
- data_shapestr or tuple, optional
A string or tuple describing the quantity of data used
- algorithm_paramsstr, optional
A string describing the parameters used by the algorithm
- commentsstr, optional
A string to provide any useful information
See also
PowerMeter.stop_measure
Stop the measure started with start_measure
PowerMeter.from_config
Create a PowerMeter object from a config file
PowerMeter.measure_power
Measure the power usage using a function decorator
PowerMeter.__call__
Measure the power usage using a with statement
Notes
We do not recommend using this method to monitor the energy usage of your code because it won’t automatically stop if an error is raised at some point while running. You will then have to stop the measure manually with
PowerMeter.stop_measure()
.Examples
First, create a PowerMeter (you only do to this step once).
>>> power_meter = PowerMeter.from_config("config.json")
Start measuring the code you wish to monitor
>>> power_meter.start_measure( ... package="pandas, numpy", ... algorithm="data cleaning", ... step="preprocessing", ... data_type="tabular", ... comments="Cleaning of csv files + train-test splitting" ... ) ... # do something result_of_your_code
Do not forget to stop measuring
>>> power_meter.stop_measure()