greenai.guide

Home › How do I…? › How do I measure the carbon footprint of training a model?

How do I…?

How do I measure the carbon footprint of training a model?

Updated · 1 min read

In short

Wrap your training script in an emissions tracker such as CodeCarbon, which estimates energy from your CPU, GPU and memory and converts it to carbon using the local grid. Count every run, including tuning and failures, record hardware, location and duration, and publish the result with the model. If you have no logs, a calculator such as Green Algorithms can estimate it afterwards.

Steps

  1. Add an emissions tracker to the training script and stop it in a finally block so it always closes.
  2. Give each run a project or experiment name so configurations can be compared.
  3. Record hardware, run time, location and the grid carbon intensity used.
  4. Count tuning, failed and abandoned runs as well as the final one.
  5. Put energy and emissions next to accuracy in your results table.
  6. Publish the figure in the model card or paper.

Measure while you train, not afterwards. Training figures that are logged run by run let you compare configurations on energy as well as accuracy, and give buyers and colleagues a number they can trust.

What determines the footprint?

Lacoste and colleagues identified the main factors in 2019: the location of the server and the energy grid it uses, the length of training, and the make and model of the hardware. Carbon is energy multiplied by the carbon intensity of the grid where and when the job ran.

Which tools should I use?

  • CodeCarbon, an open-source Python package, estimates energy from processor, GPU and memory power and converts it with local grid data. Its tutorials show how to track each configuration and compare accuracy against emissions, and it has guidance for clusters whose compute nodes have no internet access.
  • Green Algorithms, a calculator from Lannelongue, Grealey and Inouye, estimates a footprint from hardware, run time, memory and location, which suits jobs you didn't log.
  • The Machine Learning CO2 Impact calculator from Lacoste and colleagues does a similar estimate from hardware, hours, provider and region.

How do I publish it?

Hugging Face model cards have a co2_eq_emissions field for emissions in grams, the source of the figure, the training type (pre-training or fine-tuning), location and hardware used. Fill it in for every model you release.

Common mistakes

  • Reporting only the final run. Hyperparameter searches and failed runs are often most of the total.
  • Using one national yearly average when hourly regional data exists. See finding grid carbon intensity.
  • Giving one number with no method. State the tool, version and boundary.

The full method is in how to measure AI energy.

Sources

  1. Comparing model efficiency with carbon tracking, CodeCarbon documentation (2025)
  2. Using CodeCarbon on SLURM, CodeCarbon documentation (2025)
  3. Green Algorithms: quantifying the carbon footprint of computation, Lannelongue, Grealey and Inouye, Advanced Science (2021)
  4. Quantifying the carbon emissions of machine learning, Lacoste, Luccioni, Schmidt and Dandres (2019)
  5. Displaying carbon emissions for your model, Hugging Face Hub documentation (2026)

Join us

Help cut AI's impact on the planet

Get new guides, funding calls and directory listings by email, about once a month. Or add your product, course, PhD or research to the directories.

No tracking. Unsubscribe in one click. Other ways to join · Privacy