Python package for monitoring and recording power usage, energy consumption, and performance metrics from hardware components such as GPUs and CPUs
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wattameter-0.7.4.tar.gz.
File metadata
- Download URL: wattameter-0.7.4.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4a090dda96d36377488ab2f3be2d4c901fe73318c734dd5a3182bbbd38129a0
|
|
| MD5 |
325de27016b49a9d220735e1d43985c0
|
|
| BLAKE2b-256 |
224063db54f34826acbe0f3c267d9f9f776a72d498fa6cf31d6c5a15e8afc779
|
Provenance
The following attestation bundles were made for wattameter-0.7.4.tar.gz:
Publisher:
python-publish.yml on NREL/WattAMeter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wattameter-0.7.4.tar.gz -
Subject digest:
f4a090dda96d36377488ab2f3be2d4c901fe73318c734dd5a3182bbbd38129a0 - Sigstore transparency entry: 712723228
- Sigstore integration time:
-
Permalink:
NREL/WattAMeter@5da8bdc076add3fa1e4a02e3d3a379c180caaf4e -
Branch / Tag:
refs/tags/v0.7.4 - Owner: https://github.com/NREL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5da8bdc076add3fa1e4a02e3d3a379c180caaf4e -
Trigger Event:
release
-
Statement type:
File details
Details for the file wattameter-0.7.4-py3-none-any.whl.
File metadata
- Download URL: wattameter-0.7.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be488498a0a5b6a19273507db1221076d7a31e2d24c6ed787789885c446c4189
|
|
| MD5 |
cf7bd3ccdbf1413e882a21c6b6b0eb25
|
|
| BLAKE2b-256 |
57939ec6e93daa0759158ae76fb2d78c0f433c7aea253b782d324f08c1fdee85
|
Provenance
The following attestation bundles were made for wattameter-0.7.4-py3-none-any.whl:
Publisher:
python-publish.yml on NREL/WattAMeter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wattameter-0.7.4-py3-none-any.whl -
Subject digest:
be488498a0a5b6a19273507db1221076d7a31e2d24c6ed787789885c446c4189 - Sigstore transparency entry: 712723232
- Sigstore integration time:
-
Permalink:
NREL/WattAMeter@5da8bdc076add3fa1e4a02e3d3a379c180caaf4e -
Branch / Tag:
refs/tags/v0.7.4 - Owner: https://github.com/NREL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5da8bdc076add3fa1e4a02e3d3a379c180caaf4e -
Trigger Event:
release
-
Statement type: