Skip to content

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

Quickstart

Python

Install CodeCarbon:

pip install codecarbon

Track your code with a context manager:

from codecarbon import EmissionsTracker

tracker = EmissionsTracker()
tracker.start()

# Your code here

emissions = tracker.stop()
print(f"Emissions: {emissions} kg COâ‚‚")

Learn more →

CLI

Track any command without changing your code:

codecarbon monitor --no-api -- python train.py

Or detect your hardware:

codecarbon detect

Learn more →


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.

Section Description
Quickstart Get started in 5 minutes
Installation Install CodeCarbon
CLI Tutorial Track emissions from the command line
Python API Tutorial Track emissions in Python code
Comparing Model Efficiency Measure carbon efficiency across ML models
API Reference Full parameter documentation
Framework Examples Example usage patterns
Methodology How emissions are calculated
EcoLogits Track emissions from GenAI API calls
Discord Community Chat with us and the community

Contributors & Acknowledgements

CodeCarbon is built by a community of open-source contributors and supported by organizations committed to sustainable computing.

  • Contributors - See everyone who has contributed to the project
  • Citation - Cite CodeCarbon in your research
  • Partners - The organizations supporting this work