Skip to main content

Python package for monitoring and recording power usage, energy consumption, and performance metrics from hardware components such as GPUs and CPUs

Project description

CI

wattameter_logo

wattameter is a Python package for monitoring and recording power usage over time, among other metrics. It enables time series data collection on hardware components such as CPUs and GPUs.

Current Features

  • Track power usage for CPU (using RAPL) and GPU (using nvidia-ml-py)
  • Track GPU utilization and temperature
  • Periodically log time series data to file
  • Customizable logging and output options
  • Command-line interface for easy usage
  • Integration with SLURM for HPC environments

Installation

You can install wattameter via pip:

pip install wattameter

Usage

As a Python module

from wattameter import Tracker
from wattameter.readers import NVMLReader

tracker = Tracker(
    reader=NVMLReader((Power,)),
    dt_read=0.1,  # Time interval for reading power data (seconds)
    freq_write=600,  # Frequency (# reads) for writing power data to file
    output="power_log.txt",
)
tracker.start()
# ... your code ...
tracker.stop()

# ... or ...

with Tracker(
    reader=NVMLReader((Power,)),
    dt_read=0.1,
    freq_write=600,
    output="power_log.txt",
) as tracker:
    # ... your code ...

Command-line interface

wattameter --suffix test --id 0 --dt-read 0.1 --freq-write 600 --log-level info
Option Short Default Description
--suffix -s None Suffix for output files
--id -i None Identifier for the experiment
--dt-read -t 1 Time interval (seconds) between readings
--freq-write -f 3600 Frequency (# reads) for writing data to file
--log-level -l warning Logging level: debug, info, warning, error, critical
--help -h Show the help message and exit

Command-line interface with SLURM

For usage within SLURM jobs, we recommend using our utility functions start_wattameter and stop_wattameter in slurm.sh. Follow the example examples/slurm.sh, i.e.,

# In a Python environment with wattameter installed,
# load wattameter slurm utilities
WATTAPATH=$(python -c 'import wattameter; import os; print(os.path.dirname(wattameter.__file__))')
source "${WATTAPATH}/utils/slurm.sh"

# Run wattameter on all nodes
start_wattameter

# Input your job commands here
# ...

# Stop wattameter on all nodes
stop_wattameter

All options are the same as the regular command-line interface. The script will automatically handle the output file naming based on the provided SLURM_JOB_ID and node information.

Contributing

Contributions are welcome! Please open issues or submit pull requests.

License

See the LICENSE file for details.


NREL Software Record number: SWR-25-101

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

wattameter-0.7.3.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

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

wattameter-0.7.3-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file wattameter-0.7.3.tar.gz.

File metadata

  • Download URL: wattameter-0.7.3.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wattameter-0.7.3.tar.gz
Algorithm Hash digest
SHA256 51c154875ee5c94c5d78059648bf6f3af9ad19364677c12e353f584719248393
MD5 55fbc4ea9b56e132a0b48f8ec0f7acaf
BLAKE2b-256 aa751b93adb0909bc63d1f2f2ad4a9be29c4b4ad1c74e15d9eaea90a0ca26a23

See more details on using hashes here.

Provenance

The following attestation bundles were made for wattameter-0.7.3.tar.gz:

Publisher: python-publish.yml on NREL/WattAMeter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wattameter-0.7.3-py3-none-any.whl.

File metadata

  • Download URL: wattameter-0.7.3-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wattameter-0.7.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2be6338754885dae4f9908769ff4ee4d23f9655f1f54f1fef0f54d46271e8aa6
MD5 e44f6d33347d2dc9c979cced39ebcbc8
BLAKE2b-256 e1e4b726bf4486288d874bc0badb90fefab04ec909f9c6bf3bae63e0726621ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for wattameter-0.7.3-py3-none-any.whl:

Publisher: python-publish.yml on NREL/WattAMeter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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