Skip to content

SriyanRavuri/ai-carbon-emissions-calculator

Repository files navigation

AI Carbon Emissions Calculator — Cloud vs. On-Premise

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.

Why this exists

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.

What you can do with it

  • Estimate CO2 (kg) for a workload of N GPU-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.

Quick start

pip install -r requirements.txt
python scripts/run.py

This 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 results
  • outputs/emissions_by_option.png — emissions bar chart
  • outputs/cost_vs_emissions.png — cost/emissions scatter
  • outputs/report.md — stakeholder summary with recommendation

Project layout

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

Configure your own workload

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)

Methodology, in one paragraph

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.

Limitations

  • 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 utilisation factor for sensitivity analysis.
  • Carbon intensity is annual average; marginal/hourly intensity (which can vary 5–10×) is out of scope.

License

MIT

About

Configurable Python tool for estimating and comparing CO2 emissions of AI workloads across AWS, Azure, GCP, and on-premise scenarios — using regional grid carbon intensity and hardware power profiles. Built on CodeCarbon.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages