Track & reduce CO₂ emissions from your local computing¶
AI can benefit society in many ways, but given the energy needed to support the computing behind AI, these benefits can come at a high environmental price. Use CodeCarbon to track and reduce your CO₂ output from code running on your own hardware. For tracking emissions from remote GenAI API calls (OpenAI, Anthropic, etc.), see EcoLogits.
What we are¶
- A lightweight, easy to use Python library – Simple API to track emissions
- Open source, free & community driven – Built by and for the community
- Effective visual outputs – Put emissions in context with real-world equivalents
Computer emits CO₂. We started measuring how much¶
A single datacenter can consume large amounts of energy to run computing code. An innovative new tracking tool is designed to measure the climate impact of artificial intelligence.
Kana Lottick, Silvia Susai, Sorelle Friedler, and Jonathan Wilson. Energy Usage Reports: Environmental awareness as part of algorithmic accountability. NeurIPS Workshop on Tackling Climate Change with Machine Learning, 2019.
How it works¶
- Download package –
pip install codecarbon - Embed the code – Add a few lines to your script
- Run and track – Emissions are measured automatically
- Visualize results – See your impact in context
Seamless integration¶
Only a few lines of code:
from codecarbon import EmissionsTracker
tracker = EmissionsTracker()
tracker.start()
# Your code here
emissions = tracker.stop()
print(f"Emissions: {emissions} kg CO₂")
Quick links¶
| Section | Description |
|---|---|
| When to use CodeCarbon | Local vs remote: CodeCarbon vs EcoLogits |
| Installation | Get started with CodeCarbon |
| Usage | Learn how to use CodeCarbon |
| API Reference | Full API documentation |
| Examples | Example usage patterns |
| Methodology | How emissions are calculated |