carbonai.MagicPowerMeter.measure_power

MagicPowerMeter.measure_power(line, cell)
%measure_power [--step STEP] [--data_type DATA_TYPE]
                   [--data_shape DATA_SHAPE]
                   [--algorithm_params ALGORITHM_PARAMS]
                   [--comments COMMENTS]
                   power_meter package algorithm

An IPython magic function to measure the power consumption of a given cell

Parameters
power_metercarbonai.PowerMeter

A PowerMeter object used to collect the carbon logs

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 alogrithm

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

MagicPowerMeter

Loads the jupyter carbonai extension

PowerMeter

Instantiate a PowerMeter

PowerMeter.measure_power

Another way to measure the power usage of some code

Examples

Load the MagicPowerMeter extension then declare a PowerMeter as usual

%load_ext carbonai.MagicPowerMeter
from carbonai import PowerMeter
power_meter = PowerMeter(project_name="MNIST classifier",                 is_online=False, location="FR")

In each cell you want to measure, you can then use the measure_power cell magic

%%measure_power power_meter "package_name_used"                 "algorithm" --step "training" --data_type "tabular"                 --data_shape "your_data_shape"                 --algorithm_params "n_estimators=300, max_depth=15"                 --comments "Classifier trained on the MNIST dataset, 3rd test"
# Do something
positional arguments:

power_meter The PowerMeter object of this project package The name of the package used here algorithm The algorithm type used here

optional arguments:
--step STEP

Type of data used

--data_type DATA_TYPE

Type of data used

--data_shape DATA_SHAPE

Shape of the data used

--algorithm_params ALGORITHM_PARAMS

Some informative parameters used in your algorithm

--comments COMMENTS

Comments to describe what is done