Skip to main content

GPU power log

Project description

Powerlog

PyPI version

Powerlog is a lightweight command-line tool and Python package to profile Nvidia GPU power consumption during the execution of a command-line program. It uses nvidia-smi to sample power draw at regular intervals and reports total energy usage, average power, and min/max readings.

Features

  • Measures real-time GPU power draw using nvidia-smi

  • Computes:

    • Total runtime
    • Total energy consumed (in Joules)
    • Average (sampled and timed), min, and max power (Watts)
  • Outputs both summary and raw samples as CSV

  • Simple CLI interface

  • Reports Avg Power Sampled (mean of all readings) and Avg Power Timed (energy divided by total time)

Installation

Requires Python 3.6+ and NVIDIA's nvidia-smi available in your system PATH.

Project page at the Python Package Index (PyPI): https://pypi.org/project/powerlog/

Install with pip:

pip install powerlog

Usage

powerlog --output power_report.csv --gpu 1 ./my_gpu_program arg1 arg2

CLI Options

Argument Description
--output Base name for the output CSV files
--gpu Number of GPUs to monitor (default: 1)
cmd Command and arguments to run and profile

Output

If --output power.csv is specified:

  • power.csv: Summary of runtime, energy, and power stats
  • power_samples.csv: Raw timestamped power draw samples

Example

powerlog --output matrix_power.csv --gpu 1 nvidia-smi

This will generate matrix_power.csv and matrix_power_samples.csv

Demo content of matrix_power.csv:

Total Time (s),Total Energy (J),Avg Power Sampled (W),Avg Power Timed (W),Min Power Sampled (W),Max Power Sampled (W)
0.1001,1.2856,12.8400,12.8400,12.84,12.84

Demo content of matrix_power_samples.csv:

Timestamp (ns),Power Draw (W)
1752198440220994393,12.84

Dependencies

  • Python standard library (subprocess, argparse, time, csv)
  • NVIDIA GPU with drivers and nvidia-smi tool

How power and energy are calculated?

Power log collection

Powerlog uses nvidia-smi to measure GPU power draw at regular intervals (default: every 0.1 seconds). The Python wrapper script automatically runs this measurement loop from the start to the end of your program.

Total energy consumption computation

Total energy E (in Joules) is computed as $$ E = \sum_{i=1}^N P_i \cdot \Delta t_i $$

where:

  • N: total number of sampling intervals
  • Pi: GPU power draw (Watts) at interval i
  • Δti: elapsed time (seconds) between sample i and sample i-1

Development

Local Testing

To test Powerlog locally during development (before releasing to PyPI), you can install your package in "editable" mode:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Publishing to PyPI

When the package is ready to publish (or update) Powerlog on PyPI, use the following commands:

python -m pip install --upgrade build
python3 -m build
python3 -m pip install --upgrade twine
twine upload dist/*

This will build the distribution files (.tar.gz and .whl) and upload them to PyPI.

It requires API token for authentication.

Changelog

See the Changelog.md file in this repository for version history and release notes.

License

MIT License

Acknowledgments

  • Developed as part of GPU power-efficiency profiling experiments in Datalog-based engines.
  • Inspired by the EUMaster4HPC

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

powerlog-0.0.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

powerlog-0.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file powerlog-0.0.2.tar.gz.

File metadata

  • Download URL: powerlog-0.0.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for powerlog-0.0.2.tar.gz
Algorithm Hash digest
SHA256 faf421c56606e858bd172f2cbbbf546e6012da2491bfb48fbc69413716fcc9f4
MD5 a1a60140844b4e4930d1985437345ed7
BLAKE2b-256 b40a519b34ca075160563093807b8bf744ecb9eea75a1e2a789538393cbeab4c

See more details on using hashes here.

File details

Details for the file powerlog-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: powerlog-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for powerlog-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f674dfc17844b2f303531d53d95cee32934c25a228dd18e190f8a2b5f936c4a9
MD5 b44bfa50244a8f1091e55cda14e538e0
BLAKE2b-256 991ff6f30ef2f23455f18b0d9919e5ae582653d6149cf89a8887615056cc0951

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page