CodeCarbon API

CodeCarbon API

Warning

This mode use the CodeCarbon API to upload the timeseries of your emissions on a central server. All data will be public!

Before using it, you need an experiment_id, to get one, run:

codecarbon init

It will create an experiment_id for the default project and save it to codecarbon.config

Then you can tell CodeCarbon to monitor your machine:

codecarbon monitor

Or use the API in your code:

from codecarbon import track_emissions

@track_emissions(save_to_api=True)
def train_model():
    # GPU intensive training code  goes here

if __name__ =="__main__":
    train_model()

More options could be specified in @track_emissions or in .codecarbon.config

The CodeCarbon dashboard use CodeCarbon API to get the data

The API do not have a nice web interface to create your own organization and project, you have to use OpenAPI interface for that.

And so on for your team, project and experiment.

You then have to set you experiment id in CodeCarbon, with two options:

In the code:

Or in the config file .codecarbon.config: