A configurable Python tool that estimates and compares the operational CO2 emissions of running an AI workload across cloud providers (AWS, Azure, GCP) and on-premise infrastructure, using regional grid carbon intensity data and hardware-specific power-draw profiles.
Built as an extension of the CodeCarbon approach so the same methodology that tracks training emissions in a notebook can be applied retrospectively to production planning decisions — including scenarios where vendor-reported emissions data is unavailable.
Financial institutions are increasingly required to account for the carbon footprint of their cloud and AI infrastructure under frameworks like the EU taxonomy and CSRD. Cloud providers report emissions in different ways and on different cadences; on-premise estimates often require building methodology from first principles. This tool gives a single, transparent comparison across both.
- Estimate CO2 (kg) for a workload of
NGPU-hours on a chosen hardware profile. - Compare the same workload across cloud regions (e.g.
us-east-1,eu-west-1,westeurope) and an on-premise data centre. - Sweep PUE assumptions for on-premise scenarios where measured PUE isn't available.
- Output a stakeholder-facing comparison report (CSV + charts) with cost and emissions trade-offs.
pip install -r requirements.txt
python scripts/run.pyThis runs the bundled scenario — fine-tuning a 7B-parameter model for 24 hours on 4× A100 GPUs — across 9 deployment options and writes:
outputs/comparison.csv— full numerical resultsoutputs/emissions_by_option.png— emissions bar chartoutputs/cost_vs_emissions.png— cost/emissions scatteroutputs/report.md— stakeholder summary with recommendation
ai-carbon-emissions-calculator/
├── src/carbon_calc/
│ ├── calculator.py # core energy → CO2 → cost calculation
│ ├── hardware.py # GPU/CPU power-draw profiles
│ ├── regions.py # regional grid carbon intensity + PUE
│ └── reporting.py # CSV / chart / report writers
├── data/
│ ├── carbon_intensity.csv # gCO2eq/kWh by region (sources documented in METHODOLOGY.md)
│ └── hardware_profiles.csv
├── scripts/run.py # bundled comparison scenario
├── outputs/ # generated artifacts
├── tests/
├── METHODOLOGY.md # assumptions, formulas, data sources, sensitivity
├── requirements.txt
└── README.md
from carbon_calc.calculator import Workload, compare
wl = Workload(
name="custom-finetune",
hardware="A100-80GB",
gpus=8,
hours=72,
)
df = compare(wl, scenarios=["aws:us-east-1", "azure:westeurope", "gcp:europe-west4", "onprem:nl-typical"])
print(df)Operational emissions are estimated as energy_kwh × carbon_intensity_g_per_kwh / 1000, where energy_kwh is (gpu_count × gpu_tdp_w + host_overhead_w) × hours × pue / 1000. Cloud regions use published carbon intensity figures from each provider where available, falling back to grid averages from Ember and the IEA. On-premise scenarios use country-level grid intensity and a configurable PUE band (1.4 / 1.6 / 1.8) to reflect the typical range for non-hyperscale data centres. See METHODOLOGY.md for full sourcing, assumptions, and a sensitivity analysis on the variables that matter most.
- Operational (Scope 2) emissions only — no embodied/manufacturing or Scope 3 logistics.
- Hardware power draws are nominal TDP; real draw varies with utilisation. The calculator exposes a
utilisationfactor for sensitivity analysis. - Carbon intensity is annual average; marginal/hourly intensity (which can vary 5–10×) is out of scope.
MIT