perun
perun is a Python package that calculates the energy consumption of Python scripts by sampling usage statistics from hardware interfaces. It can handle MPI applications, gather data from hundreds of nodes, and accumulate it efficiently.
Cite this software
Description
.. image:: https://raw.githubusercontent.com/Helmholtz-AI-Energy/perun/main/docs/images/full_logo.svg
| |fair-software| |openssf| |zenodo| |license| |docs| | |pypi-version| |python-version| |pypi-downloads| |black| |codecov|
.. |fair-software| image:: https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green :target: https://fair-software.eu .. |openssf| image:: https://bestpractices.coreinfrastructure.org/projects/7253/badge :target: https://bestpractices.coreinfrastructure.org/projects/7253 .. |zenodo| image:: https://zenodo.org/badge/523363424.svg :target: https://zenodo.org/badge/latestdoi/523363424 .. |pypi-version| image:: https://img.shields.io/pypi/v/perun .. |pypi-downloads| image:: https://img.shields.io/pypi/dm/perun .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/psf/black .. |codecov| image:: https://codecov.io/gh/Helmholtz-AI-Energy/perun/graph/badge.svg?token=9O6FSJ6I3G :target: https://codecov.io/gh/Helmholtz-AI-Energy/perun .. |python-version| image:: https://img.shields.io/badge/Python-3.9+-blue.svg :target: https://www.python.org/downloads/ .. |license| image:: https://img.shields.io/badge/License-BSD_3--Clause-blue.svg :target: https://opensource.org/licenses/BSD-3-Clause .. |docs| image:: https://readthedocs.org/projects/perun/badge/?version=latest :target: https://perun.readthedocs.io/en/latest/?badge=latest
===============================================================
perun is a Python package that calculates the energy consumption of Python scripts by sampling usage statistics from your Intel, Nvidia or AMD hardware components. It can handle MPI applications, gather data from hundreds of nodes, and accumulate it efficiently. perun can be used as a command-line tool or as a function decorator in Python scripts.
Check out the docs <https://perun.readthedocs.io/en/latest/>_ or a working example <https://github.com/Helmholtz-AI-Energy/perun/blob/main/examples/torch_mnist/README.md>_!
Key Features
- Measures energy consumption of Python scripts and binaries, supporting different hardware configurations
- Capable of handling MPI applications, gathering data from hundreds of nodes efficiently
- Monitor individual functions using decorators
- Tracks energy usage of the application over multiple executions
- Easy to benchmark applications and functions
- Experimental!: Can monitor any non-distributed command line application
Quick Start
Installation ^^^^^^^^^^^^
From PyPI:
.. code:: console
$ pip install perun
Extra dependencies like nvidia-smi, rocm-smi and mpi4py can be installed using pip as well:
.. code:: console
$ pip install perun[nvidia, rocm, mpi]
From Github:
.. code:: console
$ pip install git+https://github.com/Helmholtz-AI-Energy/perun
Command Line ^^^^^^^^^^^^
To use perun as a command-line tool:
.. code:: console
$ perun monitor path/to/your/script.py [args]
perun will output two files, an HDF5 style containing all the raw data that was gathered, and a text file with a summary of the results.
.. code:: text
PERUN REPORT
App name: finetune_qa_accelerate
First run: 2023-08-15T18:56:11.202060
Last run: 2023-08-17T13:29:29.969779
RUN ID: 2023-08-17T13:29:29.969779
+-----------+------------------------+-----------+-------------+--------------+-------------+-------------+-------------+---------------+-------------+
| Round # | Host | RUNTIME | ENERGY | CPU_POWER | CPU_UTIL | GPU_POWER | GPU_MEM | DRAM_POWER | MEM_UTIL |
+===========+========================+===========+=============+==============+=============+=============+=============+===============+=============+
| 0 | hkn0432.localdomain | 995.967 s | 960.506 kJ | 231.819 W | 3.240 % | 702.327 W | 55.258 GB | 29.315 W | 0.062 % |
| 0 | hkn0436.localdomain | 994.847 s | 960.469 kJ | 235.162 W | 3.239 % | 701.588 W | 56.934 GB | 27.830 W | 0.061 % |
| 0 | All | 995.967 s | 1.921 MJ | 466.981 W | 3.240 % | 1.404 kW | 112.192 GB | 57.145 W | 0.061 % |
The application has been run 7 times. In total, it has used 3.128 kWh, released a total of 1.307 kgCO2e into the atmosphere, and you paid 1.02 € in electricity for it.
Binary support (experimental) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
perun is capable of monitoring simple applications written in other languages:
.. code:: console
$ perun monitor --binary path/to/your/executable [args]
Function Monitoring ^^^^^^^^^^^^^^^^^^^
Using a function decorator
.. code:: python
import time
from perun import monitor
@monitor()
def main(n: int):
time.sleep(n)
After running with perun monitor, the report will contain:
.. code:: text
Monitored Functions
+-----------+----------------------------+---------------------+------------------+--------------------+------------------+-----------------------+
| Round # | Function | Avg Calls / Rank | Avg Runtime | Avg Power | Avg CPU Util | Avg GPU Mem Util |
+===========+============================+=====================+==================+====================+==================+=======================+
| 0 | main | 1 | 993.323±0.587 s | 964.732±0.499 W | 3.244±0.003 % | 35.091±0.526 % |
| 0 | prepare_train_features | 88 | 0.383±0.048 s | 262.305±19.251 W | 4.541±0.320 % | 3.937±0.013 % |
| 0 | prepare_validation_features| 11 | 0.372±0.079 s | 272.161±19.404 W | 4.524±0.225 % | 4.490±0.907 % |
MPI ^^^
perun is compatible with MPI applications using mpi4py:
.. code:: console
$ mpirun -n 8 perun monitor path/to/your/script.py
Docs
See the documentation <https://perun.readthedocs.io/en/latest/>_ or examples <https://github.com/Helmholtz-AI-Energy/perun/tree/main/examples>_ for more details.
Citing perun
If you found perun useful, please cite the conference paper:
::
Gutiérrez Hermosillo Muriedas, J.P., Flügel, K., Debus, C., Obermaier, H., Streit, A., Götz, M.:
perun: Benchmarking Energy Consumption of High-Performance Computing Applications.
In: Cano, J., Dikaiakos, M.D., Papadopoulos, G.A., Pericàs, M., and Sakellariou, R. (eds.)
Euro-Par 2023: Parallel Processing. pp. 17–31. Springer Nature Switzerland, Cham (2023).
https://doi.org/10.1007/978-3-031-39698-4_2
.. code-block:: bibtex
@InProceedings{10.1007/978-3-031-39698-4_2, author="Guti{'e}rrez Hermosillo Muriedas, Juan Pedro and Fl{"u}gel, Katharina and Debus, Charlotte and Obermaier, Holger and Streit, Achim and G{"o}tz, Markus", editor="Cano, Jos{'e} and Dikaiakos, Marios D. and Papadopoulos, George A. and Peric{`a}s, Miquel and Sakellariou, Rizos", title="perun: Benchmarking Energy Consumption of High-Performance Computing Applications", booktitle="Euro-Par 2023: Parallel Processing", year="2023", publisher="Springer Nature Switzerland", address="Cham", pages="17--31", isbn="978-3-031-39698-4" }
- BSD-3-Clause
Participating organisations
Reference papers
Mentions
- 1.Author(s): William F. Godoy, Oscar Hernandez, Paul R. C. Kent, Maria Patrou, Kazi Asifuzzaman, Narasinga Rao Miniskar, Pedro Valero-Lara, Jeffrey S. Vetter, Matthew D. Sinclair, Jason Lowe-Power, Bobby R. BrucePublished in Lecture Notes in Computer Science, High Performance Computing by Springer Nature Switzerland in 2025, page: 177-19010.1007/978-3-032-07612-0_14
- 2.Author(s): Leonhard Duda, Khadijeh Alibabaei, Elena Vollmer, Leon Klug, Valentin Kozlov, Lisana Berberi, Mishal Benz, Rebekka Volk, Juan Pedro Gutiérrez Hermosillo Muriedas, Markus Götz, Judith Sáinz-Pardo Díaz, Álvaro López García, Frank Schultmann, Achim StreitPublished in Lecture Notes in Computer Science, Computational Science and Its Applications – ICCSA 2025 by Springer Nature Switzerland in 2025, page: 285-30210.1007/978-3-031-97000-9_18
- 1.Author(s): Maximilian Kodetzki, Tabea Bordis, Alex Potanin, Ina SchaeferPublished in Proceedings of the 2025 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software by ACM in 2025, page: 99-11510.1145/3759429.3762623
- 2.Author(s): Yasintha Rumesh, Pawani Porambage, Ijaz AhmadPublished in 2025 International Conference on Software, Telecommunications and Computer Networks (SoftCOM) by IEEE in 2025, page: 1-610.23919/softcom66362.2025.11197401
- 3.Author(s): Elias Werner, Anton Rygin, Andreas Gocht-Zech, Sebastian Döbel, Matthias LieberPublished in SC24-W: Workshops of the International Conference for High Performance Computing, Networking, Storage and Analysis by IEEE in 2024, page: 2003-201110.1109/scw63240.2024.00250
- 4.Author(s): Alper Kanak, Serhat Ege İnanç, Sercan Tanrıseven, İbrahim Arif, Cengiz Bektaş, Oguzhan Herkiloğlu, Ali Serdar Atalay, Salih ErgünPublished in 2024 International Symposium ELMAR by IEEE in 2024, page: 153-15610.1109/elmar62909.2024.10694222
- 5.Author(s): Roblex Nana Tchakoute, Claude Tadonki, Petr Dokladal, Youssef MesriPublished in 2024 International Symposium on Computer Architecture and High Performance Computing Workshops (SBAC-PADW) by IEEE in 2024, page: 12-2210.1109/sbac-padw64858.2024.00014
- 6.Author(s): Chelsea Maria John, Stepan Nassyr, Carolin Penke, Andreas HertenPublished in SC24-W: Workshops of the International Conference for High Performance Computing, Networking, Storage and Analysis by IEEE in 2024, page: 1164-117610.1109/scw63240.2024.00158
- 7.Author(s): Jan Debus, Charlotte Debus, Günther Dissertori, Markus GötzPublished in 2024 Neuro Inspired Computational Elements Conference (NICE) by IEEE in 2024, page: 1-910.1109/nice61972.2024.10549584
- 8.Author(s): Alexander Van Der Staay, Raphael Fischer, Sebastian BuschjägerPublished in 2024 IEEE/ACM Symposium on Edge Computing (SEC) by IEEE in 2024, page: 1-1410.1109/sec62691.2024.00015
- 1.Author(s): Min-Kyu Kim, Tae-An Yoo, Ji-Bum ChungPublished in IEEE Access by Institute of Electrical and Electronics Engineers (IEEE) in 2026, page: 18881-1889610.1109/access.2026.3659894
- 2.Author(s): Wadim Koslow, Fabian Hoppe, Kathrin Rack, Hakan Akdag, Alexander Rüttgers, Achim BasermannPublished in 202610.1177/10943420261444764
- 3.Author(s): Yiming Wang, Weizhe Zhang, Meng Hao, Weizhi Kong, Yuan WenPublished in ACM Transactions on Architecture and Code Optimization by Association for Computing Machinery (ACM) in 2025, page: 1-2310.1145/3716872
- 4.Author(s): Elena Vollmer, Julian Ruck, Rebekka Volk, Frank SchultmannPublished in ISPRS Journal of Photogrammetry and Remote Sensing by Elsevier BV in 2025, page: 505-51810.1016/j.isprsjprs.2025.06.006
- 5.Author(s): Elena Vollmer, Mishal Benz, James Kahn, Leon Klug, Rebekka Volk, Frank Schultmann, Markus GötzPublished in IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing by Institute of Electrical and Electronics Engineers (IEEE) in 2025, page: 6206-621610.1109/jstars.2025.3537330
- 6.Author(s): Maximilian Dauner, Gudrun SocherPublished in Frontiers in Communication by Frontiers Media SA in 202510.3389/fcomm.2025.1572947
- 7.Author(s): Joseph Arnold Xavier, Juan Pedro Gutiérrez Hermosillo Muriedas, Stepan Nassyr, Rocco Sedona, Markus Götz, Achim Streit, Morris Riedel, Gabriele CavallaroPublished in IEEE Access by Institute of Electrical and Electronics Engineers (IEEE) in 2024, page: 181679-18169210.1109/access.2024.3507193
- 8.Author(s): Charlotte Debus, Marie Piraud, Achim Streit, Fabian Theis, Markus GötzPublished in Nature Machine Intelligence by Springer Science and Business Media LLC in 2023, page: 1176-117810.1038/s42256-023-00750-1
- 1.Author(s): Chelsea Maria John, Stepan Nassyr, Carolin Penke, Andreas HertenPublished by arXiv in 202410.48550/arxiv.2409.12994
- 2.Author(s): Joseph Xavier Arnold, Juan Pedro Gutiérrez Hermosillo Muriedas, Stepan Nassyr, Rocco Sedona, Markus Götz, Achim Streit, Morris Riedel, Gabriele CavallaroPublished by Institute of Electrical and Electronics Engineers (IEEE) in 202410.36227/techrxiv.171085046.60925150/v1
- 3.Author(s): Raphael Fischer, Alexander van der Staay, Sebastian BuschjägerPublished by Research Square Platform LLC in 202410.21203/rs.3.rs-3793927/v1
Contributors
Contact person
Juan Pedro Gutiérrez Hermosillo Muriedas
Owner
Karlsruhe Institut für Technologie
0000-0001-8439-7145
Mail Juan PedroRelated projects
Helmholtz AI
Democratizing AI
HiRSE
Joint Lab Helmholtz Information - Research Software Engineering