Green AI research Research-backed Python

greeninferMeasure latency, energy, CO2 and cost per prediction for tree models

greeninfer measures latency, throughput, energy, CO2 and cost per prediction for XGBoost, LightGBM, CatBoost, scikit-learn and any model with a predict method, with repeats, idle-power subtraction and the settings recorded, so results can go in a paper or a cost review.

PyPI pip install greeninfer

Free · MIT license · runs on your machine · no signup PyPI ↗GitHub ↗

Why this matters now

Training gets the headlines, but inference runs every time a customer loads a page. For a deployed model, serving energy and cost add up to more than training ever did.

How greeninfer works

Training gets most of the attention in green AI, but a model in production is called millions of times. greeninfer measures what each prediction really costs: latency percentiles, throughput, energy per thousand predictions, CO2 and machine cost per million, across batch sizes from single-row serving to large batches.

It reads hardware energy counters (RAPL) where Linux exposes them and falls back to a clearly labelled CPU-time estimate everywhere else, including Google Colab. Every result records the method, CPU and library versions, so runs are reproducible and honest in a paper.

A Colab notebook is included that saves data, models and results to Google Drive, so a disconnect never loses work.

This package comes out of my research on energy-efficient inference for gradient-boosted trees in e-commerce and health.

Try it

pip install greeninfer

Free and open source under the MIT license. Want this done for your store, or need help with the findings? Book a call.

Agent skill included

Let your AI coding agent run greeninfer for you

The gbdt-inference-benchmark skill works with Claude Code, Codex, Cursor, Gemini CLI and other agents that read SKILL.md files. It runs the tool, explains each finding in plain words and helps you fix it.

npx skills add MuhammadAhmadZia/greeninfer --skill gbdt-inference-benchmark

Using the Claude or ChatGPT apps instead? Download the skill ZIP from the GitHub releases page and upload it under Skills.

See all 30 agent skills →

Questions about greeninfer

Is the energy number measured or estimated?

On Linux machines with readable RAPL counters it is measured, with idle power subtracted. Elsewhere, including Colab, it is the Green Algorithms CPU-time estimate. The report always says which, and why RAPL was not used.

How do I know the results are stable?

Each number is the median of several timed runs (three by default), with the minimum and maximum saved, and the summary warns when runs differ by more than 10%.

Does it work on Colab?

Yes. Colab has no RAPL counters, so energy is a CPU-time estimate, and the output says so.

Can I compare XGBoost and LightGBM?

Yes. Pass a dictionary of models and it benchmarks them on the same rows and batch sizes.

UN Sustainable Development Goals

How each tool maps to SDG targets →

Want this set up and tuned for your store?

The tools are free. If you would rather have the checks run, the findings fixed and the results measured for you, that is what I do for clients.