CodeCarbon

Track emissions from Compute and recommend ways to reduce their impact on the environment.
https://github.com/mlco2/codecarbon

Category: Consumption
Sub Category: Computation and Communication

Keywords

ai-ethics carbon-emissions carbon-footprint co2-emissions energy-consumption energy-efficiency fairness sustainability

Keywords from Contributors

language-model climate-change natural-language-processing transformer bert climate-science climate-data electricitymap flax speech-recognition

Last synced: about 19 hours ago
JSON representation

Repository metadata

Track emissions from Compute and recommend ways to reduce their impact on the environment.

README.md

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

  • 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.

Installation

pip install codecarbon

If you use Conda:

conda activate your_env
pip install codecarbon

More installation options: installation docs.

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.

calculation Summary

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

Visualize

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

dashboard

Quick links

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 (scikit-learn) Task-oriented ML framework examples
Methodology How emissions are calculated
EcoLogits Track emissions from GenAI API calls

Links

  • Main website to learn why we do this.
  • Dashboard to see your emissions.
  • Documentation to learn how to use the package and our methodology.
  • EcoLogits to track emissions from GenAI API calls (OpenAI, Anthropic, etc.).
  • GitHub to look at the source code and contribute.
  • Discord to chat with us.

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, you can find a citation under a variety of formats on Zenodo.

@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

Star History Chart


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 3 days ago

Total Commits: 2,322
Total Committers: 116
Avg Commits per committer: 20.017
Development Distribution Score (DDS): 0.86

Commits in past year: 502
Committers in past year: 38
Avg Commits per committer in past year: 13.211
Development Distribution Score (DDS) in past year: 0.791

Name Email Commits
benoit-cty 6****y 326
benoit-cty 4****y@u****v 325
vict0rsch v****h@p****e 193
Kamal Goyal g****l@b****m 182
inimaz 4****z 114
MarionCoutarel m****z@g****m 108
benoit-cty a****e@o****r 105
LuisBlanche l****r@g****m 83
dependabot[bot] 4****] 56
jl-datascientist j****e@g****m 51
Boris Feld l****n@g****m 48
Amine Saboni 4****e 46
Liam Connell c****m@b****m 39
patrick.lloret@protonmail.com p****t@p****m 37
Amine Saboni a****i@o****m 37
davidberenstein1957 d****n@g****m 32
benoit-cty b****y@l****v 31
benoit-cty b****y@e****m 30
Cian Cullinan c****n@g****m 25
Alexis Cruveiller a****r@g****m 24
Zhao Franklin q****o@b****u 22
OUMINA-SARA o****a@b****m 22
Mathilde Léval m****l@g****m 22
IamLRBA j****s@g****m 21
MyGodItsFull0fStars c****r@e****t 18
Mathilde Leval m****l@c****m 18
Sasha Luccioni l****s@m****c 17
Aditya Joshi 1****i@g****m 17
Kamal Nayan Goyal k****l 16
Hugues Souchard de Lavoreille h****l@g****m 14
and 86 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 7 days ago

Total issues: 405
Total pull requests: 828
Average time to close issues: 6 months
Average time to close pull requests: 22 days
Total issue authors: 193
Total pull request authors: 101
Average comments per issue: 2.56
Average comments per pull request: 0.93
Merged pull request: 640
Bot issues: 0
Bot pull requests: 69

Past year issues: 69
Past year pull requests: 178
Past year average time to close issues: about 1 month
Past year average time to close pull requests: 8 days
Past year issue authors: 36
Past year pull request authors: 27
Past year average comments per issue: 1.72
Past year average comments per pull request: 0.95
Past year merged pull request: 95
Past year bot issues: 0
Past year bot pull requests: 22

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/mlco2/codecarbon

Top Issue Authors

  • benoit-cty (62)
  • vict0rsch (26)
  • inimaz (20)
  • LiamConnell (13)
  • SaboniAmine (10)
  • dsblank (8)
  • mkbane (8)
  • stas00 (7)
  • kngoyal (6)
  • RafiullahOmar (6)
  • headscott (6)
  • qxpBlog (4)
  • pugantsov (4)
  • Lothiraldan (4)
  • mahmoodn (3)

Top Pull Request Authors

  • benoit-cty (153)
  • inimaz (137)
  • dependabot[bot] (69)
  • prmths128 (69)
  • SaboniAmine (66)
  • vict0rsch (30)
  • Lothiraldan (20)
  • MyGodItsFull0fStars (19)
  • kngoyal (18)
  • cianc (17)
  • IamLRBA (12)
  • LiamConnell (12)
  • LuisBlanche (11)
  • Copilot (11)
  • mathilde-leval (8)

Top Issue Labels

  • enhancement (93)
  • bug (56)
  • good first issue (55)
  • documentation (35)
  • question (26)
  • dataforgood (20)
  • API (16)
  • help wanted (14)
  • P1 (10)
  • security (8)
  • Dashboard (8)
  • P2 (7)
  • wontfix (6)
  • P3 (6)
  • docs (5)
  • invalid (1)
  • Expand contributors (1)
  • duplicate (1)

Top Pull Request Labels

  • dependencies (69)
  • python (25)
  • API (23)
  • javascript (20)
  • security (17)
  • enhancement (14)
  • bug (6)
  • python:uv (6)
  • Dashboard (4)
  • invalid (2)
  • dataforgood (2)
  • docs (1)
  • documentation (1)
  • good first issue (1)

Package metadata

pypi.org: codecarbon

  • Homepage: https://codecarbon.io/
  • Documentation: https://docs.codecarbon.io/
  • Licenses: MIT
  • Latest release: 3.2.6 (published 27 days ago)
  • Last Synced: 2026-04-24T08:39:15.334Z (2 days ago)
  • Versions: 71
  • Dependent Packages: 36
  • Dependent Repositories: 806
  • Downloads: 217,890 Last month
  • Docker Downloads: 430,060
  • Rankings:
    • Dependent packages count: 0.372%
    • Dependent repos count: 0.423%
    • Average: 0.73%
    • Docker downloads count: 0.955%
    • Downloads: 1.169%
  • Maintainers (1)
proxy.golang.org: github.com/mlco2/codecarbon

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/mlco2/codecarbon#section-documentation
  • Licenses: mit
  • Latest release: v3.2.6+incompatible (published 27 days ago)
  • Last Synced: 2026-04-07T03:01:23.684Z (19 days ago)
  • Versions: 62
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.432%
    • Average: 5.615%
    • Dependent repos count: 5.797%
conda-forge.org: codecarbon

Emissions Tracker is a Python package for tracking the carbon emissions produced by various kinds of computer programs, from straightforward algorithms to deep neural networks. By taking into account your computing infrastructure, location, usage and running time, Emissions Tracker can provide an estimate of how much CO2 you produced, and give you some comparisons with common modes of transporation to give you an order of magnitude.

  • Homepage: https://pypi.org/project/codecarbon/
  • Licenses: MIT
  • Latest release: 2.1.4 (published over 3 years ago)
  • Last Synced: 2026-03-10T03:28:53.336Z (about 2 months ago)
  • Versions: 7
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 35,074 Total
  • Rankings:
    • Stargazers count: 15.742%
    • Forks count: 18.727%
    • Average: 19.538%
    • Dependent packages count: 19.581%
    • Dependent repos count: 24.103%
conda-forge.org: codecarbon-test

Emissions Tracker is a Python package for tracking the carbon emissions produced by various kinds of computer programs, from straightforward algorithms to deep neural networks. By taking into account your computing infrastructure, location, usage and running time, Emissions Tracker can provide an estimate of how much CO2 you produced, and give you some comparisons with common modes of transporation to give you an order of magnitude.

  • Homepage: https://pypi.org/project/codecarbon/
  • Licenses: MIT
  • Latest release: 2.1.4 (published over 3 years ago)
  • Last Synced: 2026-03-10T03:28:10.264Z (about 2 months ago)
  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 19,106 Total
  • Rankings:
    • Stargazers count: 15.583%
    • Forks count: 19.206%
    • Average: 24.409%
    • Dependent packages count: 28.82%
    • Dependent repos count: 34.025%
conda-forge.org: codecarbon-viz

Emissions Tracker is a Python package for tracking the carbon emissions produced by various kinds of computer programs, from straightforward algorithms to deep neural networks. By taking into account your computing infrastructure, location, usage and running time, Emissions Tracker can provide an estimate of how much CO2 you produced, and give you some comparisons with common modes of transporation to give you an order of magnitude.

  • Homepage: https://pypi.org/project/codecarbon/
  • Licenses: MIT
  • Latest release: 2.1.4 (published over 3 years ago)
  • Last Synced: 2026-03-10T03:25:28.554Z (about 2 months ago)
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 19,055 Total
  • Rankings:
    • Stargazers count: 15.583%
    • Forks count: 19.206%
    • Average: 29.998%
    • Dependent repos count: 34.025%
    • Dependent packages count: 51.175%
conda-forge.org: codecarbon-dev

Emissions Tracker is a Python package for tracking the carbon emissions produced by various kinds of computer programs, from straightforward algorithms to deep neural networks. By taking into account your computing infrastructure, location, usage and running time, Emissions Tracker can provide an estimate of how much CO2 you produced, and give you some comparisons with common modes of transporation to give you an order of magnitude.

  • Homepage: https://pypi.org/project/codecarbon/
  • Licenses: MIT
  • Latest release: 2.1.4 (published over 3 years ago)
  • Last Synced: 2026-04-08T09:55:27.014Z (18 days ago)
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Stargazers count: 15.583%
    • Forks count: 19.206%
    • Average: 29.998%
    • Dependent repos count: 34.025%
    • Dependent packages count: 51.175%

Dependencies

carbonserver/docker/requirements-dev.txt pypi
  • alembic * development
  • fastapi * development
  • fastapi-pagination * development
  • psycopg2 * development
  • pydantic * development
  • requests * development
  • sqlalchemy * development
  • tox * development
  • uvicorn * development
carbonserver/requirements-dev.txt pypi
  • alembic * development
  • bcrypt * development
  • dependency-injector * development
  • fastapi * development
  • fastapi-pagination * development
  • psycopg2-binary * development
  • pydantic * development
  • python-dateutil * development
  • requests * development
  • sqlalchemy * development
  • tox * development
  • uvicorn * development
carbonserver/requirements.txt pypi
  • alembic *
  • bcrypt *
  • dependency-injector *
  • fastapi *
  • fastapi-pagination *
  • psycopg2-binary *
  • pydantic *
  • python-dateutil *
  • requests *
  • sqlalchemy *
  • tox *
  • uvicorn *
examples/requirements-examples.txt pypi
  • keras-tuner *
  • tensorflow *
  • torch ==1.8.1
  • torchvision *
requirements-dev.txt pypi
  • arrow * development
  • black * development
  • dash * development
  • dash_bootstrap_components * development
  • dataclasses * development
  • fire * development
  • flake8 * development
  • fuzzywuzzy * development
  • isort * development
  • mypy * development
  • pandas * development
  • psutil * development
  • py-cpuinfo * development
  • pynvml * development
  • requests * development
  • responses * development
  • sphinx * development
  • sphinx-rtd-theme * development
requirements-test.txt pypi
  • fuzzywuzzy * test
  • mock * test
  • numpy * test
  • psutil * test
  • pytest * test
  • requests-mock * test
  • responses * test
  • tox * test
.github/workflows/build.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • actions/setup-python v2 composite
  • postgres 12 docker
.github/workflows/package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • actions/upload-artifact v1 composite
.github/workflows/pre-commit.yml actions
  • actions/cache v1 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • pre-commit/action v3.0.0 composite
.github/workflows/python-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
.github/workflows/release-drafter.yml actions
  • release-drafter/release-drafter v5.7.0 composite
act/Dockerfile docker
  • ubuntu 20.04 build
carbonserver/docker/Dockerfile docker
  • ubuntu 20.04 build
docker/Dockerfile docker
  • python 3.8 build
docker-compose.yml docker
  • dpage/pgadmin4 latest
  • postgres 12
dashboard/requirements-new.txt pypi
  • codecarbon >=2.0.0
  • dash >=2.2.0
  • dash_bootstrap_components *
  • plotly >=5.6.0
dashboard/requirements.txt pypi
  • codecarbon >=2.0.0
  • dash >=2.2.0
  • gunicorn *
  • plotly >=5.6.0
requirements.txt pypi
  • codecarbon >=2.0.0
  • dash >=2.2.0
  • dash_bootstrap_components *
  • plotly >=5.6.0
carbonserver/setup.py pypi
setup.py pypi

Score: 25.80573582059112