Integrate with Comet¶
CodeCarbon integrates seamlessly with Comet, a powerful experiment tracking and visualization platform. This integration allows you to track the carbon footprint of your machine learning experiments alongside your training metrics, hyperparameters, and other experiment details.

Prerequisites¶
Before you begin, you'll need:
- A Comet account (free tier available)
- Your Comet API key (available in your account settings)
Installation¶
Install the required Comet ML library:
pip install comet_ml>=3.2.2
Setup Steps¶
Step 1: Create a Comet Account¶
- Go to Comet's website and create a free account
- From your account settings page, copy your personal API key
Step 2: Configure Your Experiment¶
In your Python script, initialize a Comet experiment with your API key:
from comet_ml import Experiment
from codecarbon import EmissionsTracker
experiment = Experiment(api_key="YOUR API KEY")
Step 3: Run Your Experiment¶
Run your experiment as normal. CodeCarbon will automatically create an EmissionsTracker object that Comet will track:
# Your training code here
model.fit(X_train, y_train)
Step 4: Add the CodeCarbon Footprint Panel¶
Once your experiment completes, view it in the Comet UI:
- Click on the
Paneltab in the left sidebar - Click
Add Panel - In the Panel Gallery, click the
Publictab - Search for
CodeCarbon Footprint - Add the panel to your experiment

Step 5: Save Your View¶
To automatically display the CodeCarbon visualization in future experiments, save your View from the Panels tab.

Example¶
A complete working example is available in the CodeCarbon repository at examples/mnist-comet.py.
Next Steps¶
- Configure CodeCarbon to customize tracking behavior
- Send emissions data to the cloud for additional visualization options
- Explore other logging options in Log to External Systems