energymeter
A Python tool to measure the energy consumption of software
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.7%) to scientific vocabulary
Keywords
Repository
A Python tool to measure the energy consumption of software
Basic Info
Statistics
- Stars: 11
- Watchers: 1
- Forks: 4
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
EnergyMeter
EnergyMeter is a Python module that combines pyRAPL, NVIDIA-SMI and eBPF to estimate the energy consumption of CPU, memory, GPU, and storage on Linux with only three lines of code. This was developed during the development of the article Fadel Argerich, M., & Patiño-Martínez, M. (2024). Measuring and Improving the Energy Efficiency of Large Language Models Inference. IEEE Access.
How to install
You can install EnergyMeter by cloning this repository and using pip:
git clone https://github.com/maufadel/EnergyMeter.git
cd EnergyMeter
pip install .
How to use
The most basic usage of EnergyMeter is as follows: ``` from energy_meter import EnergyMeter
em = EnergyMeter(diskavgspeed=1600*1e6, # The average speed of your storage (see below how you can get it) diskactivepower=6, # How many Watts are used when the storage is reading or writing (you can usually find it in specs of your storage) diskidlepower=1.42, # How many Watts are used when the storage is idle (you can usually find it in specs of your storage) label="Test Meter", # A label to identify the measurement include_idle=False) # If energy used during idle should be accounted for in the measurement. Defaults to False.
em.begin()
--> CODE YOU WANT TO MEASURE <--
em.end()
Plot energy consumption per component.
meter.plottotaljoulespercomponent()
or print(em.gettotaljoulespercomponent())
```

You can check the notebook Measuringenergyconsumption.ipynb for more details.
How to get storage details
You can benchmark your storage speed with the Flexible I/O tester (FIO) as recommended by Google in the following tutorial: https://cloud.google.com/compute/docs/disks/benchmarking-pd-performance
Storage specs usually include data regarding the power consumption during active (reading or writing) and for idle periods.
Troubleshooting
pyRAPL/RAPL
pyRAPL requires access to /sys/class/powercap/intel-rapl, for which sudo access is required. If the access is denied, run the following command on the terminal to enable access to the rapl measurement:
sudo chmod -R a+r /sys/class/powercap/intel-rapl
bpftrace
Also note that you need to have bpftrace installed. On ubuntu, you can install it with the following command:
sudo apt-get install -y bpftrace
For other operating systems, please check https://github.com/bpftrace/bpftrace/blob/master/INSTALL.md.
Limitations
EnergyMeter requires to be run on bare metal instances running Linux on Intel and NVIDIA hardware. These requirements are inherited from the tools used for tracking the energy consumption: RAPL (Intel), NVIDIA-SMI (NVIDIA), and eBPF (Linux). These tools are known to have a high accuracy thanks to their access to low level sensors, but it is important to keep in mind that the energy consumption metrics provided are still estimations and vary according to different factors including hardware configuration and software versions. Additionally, the energy consumed by cooling, screens and other components not mentioned here are not included in our measurements, so the total energy consumed will likely be different to the total sum of the consumption of CPU, memory, GPU, and storage.
Authorship and License
I am developing EnergyMeter as a part of my PhD program at Universidad Politécnica de Madrid. EnergyMeter is open sourced under an MIT License.
If you found this repository useful, please cite our work:
@article{argerich2024measuring,
title={Measuring and Improving the Energy Efficiency of Large Language Models Inference},
author={Fadel Argerich, Mauricio and Pati{\~n}o-Mart{\'\i}nez, Marta},
journal={IEEE Access},
year={2024},
publisher={IEEE}
}
Owner
- Name: Mauricio Fadel Argerich
- Login: maufadel
- Kind: user
- Location: Heidelberg, Germany
- Repositories: 1
- Profile: https://github.com/maufadel
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "Fadel Argerich" given-names: "Mauricio" orcid: "https://orcid.org/0009-0008-9348-8426" title: "EnergyMeter" version: 1.0.0 date-released: 2023-07-04 url: "https://github.com/maufadel/EnergyMeter"
GitHub Events
Total
- Issues event: 2
- Watch event: 6
- Issue comment event: 1
- Push event: 8
- Pull request event: 1
- Fork event: 2
- Create event: 1
Last Year
- Issues event: 2
- Watch event: 6
- Issue comment event: 1
- Push event: 8
- Pull request event: 1
- Fork event: 2
- Create event: 1
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Mauricio Fadel Argerich | m****l@i****m | 15 |
Issues and Pull Requests
Last synced: about 2 years ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- kirill406 (1)
Pull Request Authors
- maufadel (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- Jinja2 ==3.1.5
- MarkupSafe ==3.0.2
- PyYAML ==6.0.2
- certifi ==2025.1.31
- charset-normalizer ==3.4.1
- contourpy ==1.3.1
- cycler ==0.12.1
- dnspython ==2.7.0
- filelock ==3.17.0
- fonttools ==4.55.8
- fsspec ==2025.2.0
- huggingface-hub ==0.28.1
- idna ==3.10
- kiwisolver ==1.4.8
- matplotlib ==3.10.0
- mpmath ==1.3.0
- networkx ==3.4.2
- numpy ==2.2.2
- nvidia-cublas-cu12 ==12.4.5.8
- nvidia-cuda-cupti-cu12 ==12.4.127
- nvidia-cuda-nvrtc-cu12 ==12.4.127
- nvidia-cuda-runtime-cu12 ==12.4.127
- nvidia-cudnn-cu12 ==9.1.0.70
- nvidia-cufft-cu12 ==11.2.1.3
- nvidia-curand-cu12 ==10.3.5.147
- nvidia-cusolver-cu12 ==11.6.1.9
- nvidia-cusparse-cu12 ==12.3.1.170
- nvidia-cusparselt-cu12 ==0.6.2
- nvidia-ml-py ==12.570.86
- nvidia-nccl-cu12 ==2.21.5
- nvidia-nvjitlink-cu12 ==12.4.127
- nvidia-nvtx-cu12 ==12.4.127
- packaging ==24.2
- pandas ==2.2.3
- pillow ==11.1.0
- pyRAPL ==0.2.3.1
- pymongo ==4.11
- pynvml ==12.0.0
- pyparsing ==3.2.1
- python-dateutil ==2.9.0.post0
- pytz ==2025.1
- requests ==2.32.3
- safetensors ==0.5.2
- six ==1.17.0
- sympy ==1.13.1
- timm ==1.0.14
- torch ==2.6.0
- torchvision ==0.21.0
- tqdm ==4.67.1
- triton ==3.2.0
- typing_extensions ==4.12.2
- tzdata ==2025.1
- urllib3 ==2.3.0
- matplotlib *
- numpy *
- pandas *
- pyRAPL *
- pynvml *