Skip to main content

banner

Track & reduce CO₂ emissions from your local computing

Estimate and track carbon emissions from your computer, quantify and analyze their impact.

DOI OpenSSF Scorecard codecov Discord

  • 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

Tracking GenAI API calls? CodeCarbon measures emissions from local computing (your hardware). To track emissions from remote GenAI API calls (OpenAI, Anthropic, Mistral, etc.), use EcoLogits. Both tools are complementary.

Join the community! Have questions, want to share your work, or contribute? Join us on Discord – we're here to help and excited to hear from you!

Installation

pip install codecarbon

If you use Conda:

conda activate your_env
pip install codecarbon

More installation options: installation docs.

Something not working, or numbers that look wrong? See the troubleshooting guide.

Quickstart (Python)

from codecarbon import EmissionsTracker

tracker = EmissionsTracker()
tracker.start()

# Your code here

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

Learn more →

Quickstart (CLI)

Track a command without changing your code:

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

Detect your hardware:

codecarbon detect

Full CLI guide: CLI tutorial.

Configuration

You can configure CodeCarbon using:

  • ~/.codecarbon.config (global)
  • ./.codecarbon.config (project-local)
  • CODECARBON_* environment variables
  • Python arguments (EmissionsTracker(...))

Configuration precedence and examples: configuration guide.

How it works

We created a Python package that estimates your hardware electricity power consumption (GPU + CPU + RAM) and we apply to it the carbon intensity of the region where the computing is done.

CodeCarbon focuses on the main compute components it can measure or estimate directly: CPU, GPU, and RAM. It does not separately model disk I/O, network transfers, displays, cooling, or other peripherals because those sources are usually much smaller for local code-level experiments and are not exposed through the same low-overhead measurement interfaces.

On Linux, CodeCarbon reads Intel RAPL hardware energy counters when it can. If those counters are not readable it falls back to estimating from CPU load, which is less accurate — see getting accurate CPU measurements to enable them.

calculation Summary

We explain more about this calculation in the Methodology section of the documentation, and we document how close those numbers are — and where they are not close — in Accuracy and validation.

Visualize

You can visualize your experiment emissions on the dashboard or locally with carbonboard.

dashboard

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
Accurate CPU measurements (Linux/RAPL) Read real energy counters instead of estimating
API Reference Full parameter documentation
Framework examples (scikit-learn) Task-oriented ML framework examples
Methodology How emissions are calculated
Accuracy and validation How accurate the numbers are, and why
Alternatives comparison CodeCarbon vs other carbon tracking tools
When to use CodeCarbon vs EcoLogits Choose the right tool
EcoLogits Track emissions from GenAI API calls
Discord Community Chat with us and the community

Contributing

We are hoping that the open-source community will help us edit the code and make it better!

You are welcome to open issues, even suggest solutions and better still contribute the fix/improvement! We can guide you if you're not sure where to start but want to help us out.

Check out our contribution guidelines.

Feel free to chat with us on Discord.

Citation

If you find CodeCarbon useful for your research, use the Cite this repository button in the GitHub sidebar, or copy the BibTeX below. The DOI is a Zenodo concept DOI: it always resolves to the latest release. All versions and formats are on Zenodo.

@software{codecarbon,
  author       = {Benoit Courty and
                  Amine Saboni and
                  Iñigo Imaz Chacón and
                  Sasha Luccioni and
                  Victor Schmidt and
                  Boris Feld and
                  David Berenstein and
                  Jérémy Lecourt and
                  Mathilde Léval and
                  Luis Blanche and
                  Marion Coutarel and
                  Alexis Bogroff and
                  Patrick Lloret and
                  {The CodeCarbon contributors}},
  title        = {CodeCarbon: Estimate and track carbon emissions from computing},
  publisher    = {Zenodo},
  version      = {3.3.3},
  doi          = {10.5281/zenodo.4658424},
  url          = {https://doi.org/10.5281/zenodo.4658424}
}

Contact

Feel free to chat with us on Discord.

Codecarbon was formerly developed by volunteers from Mila and the DataForGoodFR community alongside donated professional time of engineers at Comet.ml and BCG GAMMA.

Now CodeCarbon is supported by Code Carbon, a French non-profit organization whose mission is to accelerate the development and adoption of CodeCarbon.

Sponsors

Clever Cloud     Data For Good     GitHub     Mozilla

Metadata

Release files for codecarbon 3.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codecarbon 3.3.3
File Size Uploaded Provenance Actions
codecarbon-3.3.3.tar.gz 524.8 kB With provenance Details for codecarbon-3.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codecarbon 3.3.3
File Interpreter ABI Platform Actions
codecarbon-3.3.3-py3-none-any.whl Python 3 none any Details for codecarbon-3.3.3-py3-none-any.whl

Total release size: 958.3 kB

Release files / codecarbon-3.3.3.tar.gz

Download URL codecarbon-3.3.3.tar.gz
Size 524.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b55c4754f6ad245607cc6e8c790dc1d45ce5dadab177cc67bee63b46072c52ca
BLAKE2b-256 checksum
How to use checksums
8248e70a9abe59ebd6fd3b489453bbc54187bcdb3c63b345104a970718a7443f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / codecarbon-3.3.3-py3-none-any.whl

Download URL codecarbon-3.3.3-py3-none-any.whl
Size 433.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a163d6ec37ef8e1341739ba117d3b546db437d7a8c1d6d0f227c0e471806f75
BLAKE2b-256 checksum
How to use checksums
2ac2bae0ff0f82d1e4e30d29775d21950edcbc34d242b91c20a73ce0954373a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for codecarbon 3.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codecarbon-3.3.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.3.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page