+
+ +
+

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 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
+
+@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 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
+@track_emissions(
+    measure_power_secs=30,
+    api_call_interval=4,
+    experiment_id="your experiment id",
+    save_to_api=True,
+)
+def train_model():
+
+
+

Or in the config file .codecarbon.config:

+
[codecarbon]
+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.

+
+
+ + +
+