CodeCarbon API

CodeCarbon API


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 a experiment_id on the default project and save it to codecarbon.config

Then you could tell CodeCarbon to monitor your machine :

codecarbon monitor

Or use the API in your code

from codecarbon import track_emissions

def train_model():
    # GPU intensive training code  goes here
if __name__ =="__main__":

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

The CodeCarbon dasboard 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:

from codecarbon import track_emissions
    experiment_id="your experiment id",
def train_model():

Or in the config file .codecarbon.config:

experiment_id = your experiment id
save_to_api = true

But I see that you already did all that and have emissions data in the database, so we have to investigate for a bug in the interface.

Thanks for taking time to report this.