codecarbon 3.2.6


pip install codecarbon

  Latest version

Released: Mar 30, 2026


Meta
Author: Mila, DataForGood, BCG GAMMA, Comet.ml, Haverford College
Requires Python: >=3.10

Classifiers

Natural Language
  • English

Programming Language
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

banner

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

CodeCarbon websites:


DOI

OpenSSF Scorecard codecov

About CodeCarbon ๐Ÿ’ก

CodeCarbon started with a quite simple question:

What is the carbon emission impact of my computer program? :shrug:

We found some global data like "computing currently represents roughly 0.5% of the worldโ€™s energy consumption" but nothing on our individual/organisation level impact.

At CodeCarbon, we believe, along with Niels Bohr, that "Nothing exists until it is measured". So we found a way to estimate how much CO2 we produce while running our code.

How?

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.

calculation Summary

We explain more about this calculation in the Methodology section of the documentation.

Our hope is that this package will be used widely for estimating the carbon footprint of computing, and for establishing best practices with regards to the disclosure and reduction of this footprint.

So ready to "change the world one run at a time"? Let's start with a very quick set up.

Quickstart ๐Ÿš€

Installation ๐Ÿ”ง

From PyPI repository

pip install codecarbon

Using Conda environments If you're using Conda, you can install CodeCarbon with pip in your Conda environment:

conda activate your_env
pip install codecarbon

To see more installation options please refer to the documentation: Installation

Start to estimate your impact ๐Ÿ“

Without using the online dashboard

from codecarbon import track_emissions
@track_emissions()
def your_function_to_track():
  # your code

After running your code, you will find an emissions.csv that you can visualize with carbonboard --filepath="examples/emissions.csv".

With the online dashboard

To use the online dashboard you need to create an account on CodeCarbon Dashboard. Once you have an account, you can create an experiment_id to track your emissions.

To get an experiment_id enter:

! codecarbon login

You can now store it in a .codecarbon.config at the root of your project

[codecarbon]
log_level = DEBUG
save_to_api = True
experiment_id = 2bcbcbb8-850d-4692-af0d-76f6f36d79b2 #the experiment_id you get with init

Now you have 2 main options:

Monitoring your machine ๐Ÿ’ป

In your command prompt use: codecarbon monitor The package will track your emissions independently from your code.

Detecting your hardware ๐Ÿ”

In your command prompt use: codecarbon detect The package will detect and print your hardware information (RAM, CPU, GPU).

In your Python code ๐Ÿ

from codecarbon import track_emissions
@track_emissions()
def your_function_to_track():
  # your code

The package will track the emissions generated by the execution of your function.

There is other ways to use codecarbon package, please refer to the documentation to learn more about it: Usage

Visualize ๐Ÿ“Š

You can now visualize your experiment emissions on the dashboard. dashboard

Hope you enjoy your first steps monitoring your carbon computing impact! Thanks to the incredible codecarbon community ๐Ÿ’ช๐Ÿผ a lot more options are available using codecarbon including:

  • offline mode
  • cloud mode
  • comet integration...

Please explore the Documentation to learn about it If ever what your are looking for is not yet implemented, let us know through the issues and even better become one of our ๐Ÿฆธ๐Ÿผโ€โ™€๏ธ๐Ÿฆธ๐Ÿผโ€โ™‚๏ธ contributors! more info ๐Ÿ‘‡๐Ÿผ

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 ๐Ÿฅ‡

In order to contribute a change to our code base, please submit a pull request (PR) via GitHub and someone from our team will go over it and accept it.

Check out our contribution guidelines :arrow_upper_right:

Feel free to chat with us on Discord.

How To Cite ๐Ÿ“

If you find CodeCarbon useful for your research, you can find a citation under a variety of formats on Zenodo.

Here is a sample for BibTeX:

@software{benoit_courty_2024_11171501,
  author       = {Benoit Courty and
                  Victor Schmidt and
                  Sasha Luccioni and
                  Goyal-Kamal and
                  MarionCoutarel and
                  Boris Feld and
                  Jรฉrรฉmy Lecourt and
                  LiamConnell and
                  Amine Saboni and
                  Inimaz and
                  supatomic and
                  Mathilde Lรฉval and
                  Luis Blanche and
                  Alexis Cruveiller and
                  ouminasara and
                  Franklin Zhao and
                  Aditya Joshi and
                  Alexis Bogroff and
                  Hugues de Lavoreille and
                  Niko Laskaris and
                  Edoardo Abati and
                  Douglas Blank and
                  Ziyao Wang and
                  Armin Catovic and
                  Marc Alencon and
                  Michaล‚ Stฤ™chล‚y and
                  Christian Bauer and
                  Lucas Otรกvio N. de Araรบjo and
                  JPW and
                  MinervaBooks},
  title        = {mlco2/codecarbon: v2.4.1},
  month        = may,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {v2.4.1},
  doi          = {10.5281/zenodo.11171501},
  url          = {https://doi.org/10.5281/zenodo.11171501}
}

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.

Star History

Comparison of the number of stars accumulated by the different Python CO2 emissions projects: Star History Chart

3.2.6 Mar 30, 2026
3.2.5 Mar 19, 2026
3.2.4 Mar 18, 2026
3.2.3 Feb 22, 2026
3.2.2 Feb 01, 2026
3.2.1 Jan 02, 2026
3.2.0 Nov 30, 2025
3.1.1 Nov 23, 2025
3.1.0 Nov 15, 2025
3.0.9 Nov 15, 2025
3.0.8 Oct 29, 2025
3.0.7 Oct 08, 2025
3.0.6 Oct 05, 2025
3.0.5 Sep 20, 2025
3.0.4 Jul 15, 2025
3.0.3 Jul 12, 2025
3.0.2 May 26, 2025
3.0.1 May 01, 2025
3.0.0 Apr 18, 2025
3.0.0rc7 Apr 11, 2025
3.0.0rc6 Apr 11, 2025
3.0.0rc5 Apr 06, 2025
3.0.0rc4 Feb 28, 2025
3.0.0rc3 Feb 20, 2025
3.0.0rc2 Feb 18, 2025
3.0.0rc1 Feb 15, 2025
3.0.0rc0 Jan 12, 2025
2.8.4 Apr 15, 2025
2.8.3 Jan 19, 2025
2.8.2 Dec 18, 2024
2.8.1 Dec 03, 2024
2.8.0 Nov 24, 2024
2.7.4 Nov 10, 2024
2.7.2 Oct 28, 2024
2.7.1 Sep 11, 2024
2.7.0 Sep 08, 2024
2.6.0 Aug 09, 2024
2.5.1 Aug 05, 2024
2.5.0 Jun 20, 2024
2.4.3rc1 May 24, 2024
2.4.2 May 21, 2024
2.4.1 May 10, 2024
2.4.0rc0 May 01, 2024
2.3.5 Apr 10, 2024
2.3.4 Jan 30, 2024
2.3.3 Jan 22, 2024
2.3.2 Nov 28, 2023
2.3.1 Aug 16, 2023
2.3.0 Aug 03, 2023
2.2.7 Jul 25, 2023
2.2.6 Jul 25, 2023
2.2.5 Jul 12, 2023
2.2.4 Jun 21, 2023
2.2.3 Jun 05, 2023
2.2.2 May 25, 2023
2.2.1 May 13, 2023
2.2.0 May 10, 2023
2.1.4 Sep 05, 2022
2.1.3 Jun 14, 2022
2.1.2 May 17, 2022
2.1.1 May 10, 2022
2.1.0 Apr 27, 2022
2.0.0 Apr 07, 2022
2.0.0a3 Mar 18, 2022
2.0.0a2 Mar 10, 2022
2.0.0a1 Mar 08, 2022
1.2.0 Apr 18, 2021
1.1.0 Mar 11, 2021
1.0.0 Dec 01, 2020
0.1.0 Nov 30, 2020
0.0.10 Nov 13, 2020

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
arrow
authlib (>=1.2.1)
click
pandas (>=2.3.3)
pandas
prometheus_client
psutil (>=6.0.0)
py-cpuinfo
pydantic
nvidia-ml-py
rapidfuzz
requests
questionary
rich
typer
pycountry