Skip to main content
https://raw.githubusercontent.com/Helmholtz-AI-Energy/perun/main/docs/_static/full_logo.svg
fair-software openssf zenodo license docs
pypi-version python-version pypi-downloads black codecov

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 or a working example!

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:

$ pip install perun

Extra dependencies like nvidia-smi, rocm-smi and mpi4py can be installed using pip as well:

$ pip install perun[nvidia, rocm, mpi]

From Github:

$ pip install git+https://github.com/Helmholtz-AI-Energy/perun

Command Line

To use perun as a command-line tool:

$ 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.

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:

$ perun monitor --binary path/to/your/executable [args]

Function Monitoring

Using a function decorator

import time
from perun import monitor

@monitor()
def main(n: int):
    time.sleep(n)

After running with perun monitor, the report will contain:

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:

$ mpirun -n 8 perun monitor path/to/your/script.py

Docs

See the documentation or 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
@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"
}

Metadata

Release files for perun 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perun 1.0.0
File Size Uploaded
perun-1.0.0.tar.gz 233.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for perun 1.0.0
File Interpreter ABI Platform
perun-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 311.3 kB

Release files / perun-1.0.0.tar.gz

Download URL perun-1.0.0.tar.gz
Size 233.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ec0ada20d91be2808a0174be2eb4828c0c6dd9ac2041695d6aa47fe556ddca4c
BLAKE2b-256 checksum
How to use checksums
54fc0d246f0ecffbc93496791b9b821940623bbb2aeea364c6d8e8bb690339b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / perun-1.0.0-py3-none-any.whl

Download URL perun-1.0.0-py3-none-any.whl
Size 77.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb563804711486609a7f6b5382f92674e4a94462a2301f1874e4c1b334579665
BLAKE2b-256 checksum
How to use checksums
e78473860eb687a9272b0779183506d6686901199587de80c98c5731543d1df9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.9

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page