codecarbon
What it is and what it does
CodeCarbon is a Python library that estimates the carbon emissions produced by your local computing hardware. It measures or estimates power consumption from CPU, GPU, and RAM, then applies the regional carbon intensity of your electricity grid to calculate CO₂ emissions in kilograms. The library offers both a programmatic API (via EmissionsTracker) and a command-line interface for tracking emissions without modifying code.
It's designed for developers and researchers who want to understand and reduce the environmental footprint of their computational work—particularly useful for machine learning experiments, data processing, and other CPU- or GPU-intensive tasks. The package integrates with a web dashboard for visualization and provides configuration through files, environment variables, or Python arguments.
Use it for:
- Measure carbon emissions from training machine learning models to compare efficiency across different architectures or hyperparameters
- Track total CO₂ impact of long-running data processing or scientific computing jobs to report environmental metrics
- Monitor GPU utilization and emissions during development to identify and optimize energy-intensive code paths
- Establish baseline carbon footprint for a research project and track improvements over time
- Generate emissions reports for sustainability reporting or academic papers on green computing
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Measures and tracks carbon emissions from local computing hardware (CPU, GPU, RAM) and provides estimates of their environmental impact based on regional electricity carbon intensity.
Yes, if you need to measure and track carbon emissions from local computing. The library is actively maintained, has no known vulnerabilities, installs easily, and uses a permissive MIT license. It fills a specific niche—local hardware emissions tracking—and is complementary to tools that track remote API calls. Install it if environmental impact of your code matters to your workflow or reporting requirements.
Install
codecarbon on PyPI
pip
pip install codecarbonuv
uv add codecarbonpoetry
poetry add codecarbonInstalling codecarbon
Before you install
Low friction install with a pure Python wheel. Actively maintained with a recent release; last commit within days. Supports modern Python versions (3.10–3.14). Sixteen runtime dependencies are manageable but add some weight to the dependency tree.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for commercial and research projects without licensing concerns.
Quickstart
pip install codecarbon
from codecarbon import EmissionsTracker
tracker = EmissionsTracker()
tracker.start()
# Your code here
emissions = tracker.stop()
print(f"Emissions: {emissions} kg CO₂")
Requires Python 3.10 or later. GPU tracking requires nvidia-ml-py and NVIDIA hardware; CPU-only tracking works on any system.
Verify before relying
- Accuracy of carbon intensity data by region and how frequently it is updated
- Overhead and performance impact of continuous hardware monitoring on long-running processes
- Whether disk I/O, network, and cooling are modeled or remain unmeasured
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 16 — arrow, authlib, joserfc, click, pandas, prometheus_client, psutil, py-cpuinfo, pydantic, nvidia-ml-py, rapidfuzz, requests, questionary, rich, typer, pycountry |
| Maintenance | actively maintained — 10 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 204,797/month — #9,600 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: codecarbon-3.3.0-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
graphytegraphyte sends metrics to a Graphite/Carbon…
permissive · top 15,000 on PyPI
graphitesendSends metrics to Graphite's Carbon backend over…
unclear · top 15,000 on PyPI
comet-mlComet ML is an experiment tracking and logging…
permissive · top 15,000 on PyPI
nvidia-cuda-ccclProvides NVIDIA CUDA C++ Core Compute Libraries…
unclear · top 5,000 on PyPI
joulescopeJoulescope is a Python driver for the…
permissive · top 15,000 on PyPI
nvidia-cuda-cccl-cu12Provides NVIDIA's CUDA C++ Core Compute…
unclear · top 15,000 on PyPI
cirq-googleProvides access to Google's Quantum Computing…
permissive · top 15,000 on PyPI
pyTibberPython library for querying Tibber's…
copyleft · top 15,000 on PyPI
accessCalculates spatial accessibility metrics to…
permissive · top 15,000 on PyPI
greeneye_monitorParses and processes binary data packets from…
permissive · top 15,000 on PyPI