Energy monitoring for your code

Know what your code
really costs
the planet.

EcoCode reads your machine’s real energy counters and shows you exactly what your code uses. Energy, carbon and cost, live, on Linux, macOS and Windows.

0
operating systems
0
exporters
0
framework integrations
0+
country carbon table
train.py | ecocode
1
2 
3
4 
5
6
7
8
9
$python train.py✓ Run published to dashboard
ecocode.harmonyhpc.io/{workspace}/runs/{run-id}
EcoCode live run view showing energy charts and the training phase timeline

Live run view. Charts update every second while the run is in progress.

What EcoCode does

Measure, attribute, compare

Most energy tools estimate from manufacturer TDP figures. EcoCode reads what the hardware reports and tells you how much of it was yours.

Real hardware readings

RAPL on Linux, Apple energy counters on macOS, the Energy Meter Interface on Windows, and NVIDIA NVML for GPUs. The same counters the hardware uses to manage its own power.

Not TDP × utilisation.

Per-process attribution, GPUs included

CPU and memory energy are split by the share your process tree actually used. Each GPU is read independently from its own energy counter and attributed by per-process utilisation.

Per socket, per GPU.

Any language, plus a Python SDK

Wrap anything with the CLI: python, node, a compiled binary. Inside Python, add phase, step and loss markers so energy lines up with what the model was doing.

Zero changes to the target program.

Live team dashboard

Charts update every second while a run is in progress. Group runs into projects, share a workspace with your team, and get carbon, cost and a 0.5 to 5 leaf rating for every run.

Carbon from Ember grid data for your country or US state.

How it works

Three steps to your first run

No agent to deploy, no infrastructure to manage. The dashboard is hosted; the measuring happens on your machine.

  1. 1

    Install

    One package on Linux, macOS and Windows. The wheel bundles the ecocode binary. Homebrew and winget manifests are available too.

  2. 2

    Run

    Create a free account, generate an API key under Settings, and either wrap your command with the CLI or add a few lines of Python.

  3. 3

    Watch

    Energy, carbon and cost stream to the dashboard while the run is still going. Compare runs side by side when it finishes.

terminal
pip install ecocode
 
# see what this machine can measure
ecocode doctor
terminal
ecocode config set-api-key eco_...
 
# wrap any command
ecocode run -o online --project my-project -- python train.py
ecocode.harmonyhpc.io/{workspace}/runs
EcoCode runs list showing experiments with energy, CO₂ and duration columns

Every run lands in the runs list with its energy, CO₂, cost and leaf rating.

Tool comparison

How EcoCode compares

Against the energy measurement tools most often used in ML and systems research. Partial means limited or conditional support; details below.

CapabilityEcoCodeCodeCarbonScaphandreCarbonTrackerKepler
GPU energy from the NVML energy counter
Per-process GPU attribution
Per-socket, per-domain CPU and DRAM energy
Monitor any process, any language
macOS and Windows support
Built-in live dashboard
Team workspaces
Prometheus export
Live grid carbon intensity
GPU.
EcoCode and Kepler both split GPU energy across processes in proportion to each process's measured GPU utilisation. EcoCode integrates the NVML energy counter; Kepler samples power, and its GPU support is experimental and off by default. CarbonTracker samples device power with no per-process split.
CPU.
CodeCarbon and CarbonTracker read package and DRAM energy per socket but do not expose uncore; Kepler sums same-named RAPL zones across sockets.
Any process.
CodeCarbon's monitor mode estimates CPU energy from CPU time and TDP; CarbonTracker wraps a command but measures the whole machine.
Platforms.
CodeCarbon reads Apple Silicon counters through powermetrics, which needs sudo, and Windows 11 EMI. Scaphandre has a Windows RAPL driver that is no longer packaged or tested, and no macOS support. CarbonTracker supports Apple Silicon only. EcoCode needs no elevated rights on macOS or Windows.
Dashboards and Prometheus.
CodeCarbon has a hosted dashboard with organisations and projects that receives results after a run finishes, and pushes metrics to a Prometheus Pushgateway; Scaphandre and Kepler expose a pull endpoint. Kepler is Kubernetes-first but runs standalone on Linux.

Framework integrations

Works with your stack

Callbacks for HuggingFace, TRL, Lightning, DeepSpeed, vLLM, Keras and ONNX Runtime. Phases, steps and loss are recorded alongside the energy data.

HuggingFace integration
import ecocode from ecocode.integrations.huggingface import EcoCodeCallback
with ecocode.run("sft-llama3", exporter="online", api_key="eco_...") as eco_run:
trainer = Trainer(
model=model,
args=TrainingArguments(...),
callbacks=[EcoCodeCallback(eco_run)],
)
trainer.train()

Free to get started

Start measuring your impact today

Free account, hosted dashboard, nothing to deploy. Real hardware readings from the first run.

train.py
import ecocode

# That's it. Wrap your existing training loop:
with ecocode.run("my-experiment", exporter="online", api_key="eco_...") as run:
    ...
Already have an account? Sign in