{"id":30352378,"url":"https://github.com/arsho/powerlog","last_synced_at":"2025-08-19T00:21:22.254Z","repository":{"id":302363367,"uuid":"1012211779","full_name":"arsho/powerlog","owner":"arsho","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-11T02:36:11.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-16T06:55:48.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arsho.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-02T02:01:11.000Z","updated_at":"2025-07-11T02:36:14.000Z","dependencies_parsed_at":"2025-07-11T04:15:10.602Z","dependency_job_id":null,"html_url":"https://github.com/arsho/powerlog","commit_stats":null,"previous_names":["arsho/powerlog"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arsho/powerlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arsho%2Fpowerlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arsho%2Fpowerlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arsho%2Fpowerlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arsho%2Fpowerlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arsho","download_url":"https://codeload.github.com/arsho/powerlog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arsho%2Fpowerlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271079238,"owners_count":24695599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-19T00:21:20.309Z","updated_at":"2025-08-19T00:21:22.240Z","avatar_url":"https://github.com/arsho.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Powerlog\n\n[![PyPI version](https://badge.fury.io/py/powerlog.svg)](https://pypi.org/project/powerlog/)\n\n\n**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.\n\n## Features\n\n* Measures real-time GPU power draw using `nvidia-smi`\n* Computes:\n\n  * Total runtime\n  * Total energy consumed (in Joules)\n  * Average (sampled and timed), min, and max power (Watts)\n* Outputs both summary and raw samples as CSV\n* Simple CLI interface\n* Reports Avg Power Sampled (mean of all readings) and Avg Power Timed (energy divided by total time)\n\n## Installation\n\nRequires Python 3.6+ and NVIDIA's `nvidia-smi` available in your system PATH.\n\nProject page at the Python Package Index (PyPI): [https://pypi.org/project/powerlog/](https://pypi.org/project/powerlog/)\n\nInstall with pip:\n```bash\npip install powerlog\n```\n\n## Usage\n\n```bash\npowerlog --output power_report.csv --gpu 1 ./my_gpu_program arg1 arg2\n```\n\n### CLI Options\n\n| Argument     | Description                                 |\n| ------------ | ------------------------------------------- |\n| `--output`   | Base name for the output CSV files          |\n| `--gpu`      | Number of GPUs to monitor (default: 1)      |\n| `cmd`        | Command and arguments to run and profile    |\n\n## Output\n\nIf `--output power.csv` is specified:\n\n* `power.csv`: Summary of runtime, energy, and power stats\n* `power_samples.csv`: Raw timestamped power draw samples\n\n## Example\n\n```bash\npowerlog --output matrix_power.csv --gpu 1 nvidia-smi\n```\n\nThis will generate `matrix_power.csv` and `matrix_power_samples.csv`\n\nDemo content of `matrix_power.csv`:\n```text\nTotal Time (s),Total Energy (J),Avg Power Sampled (W),Avg Power Timed (W),Min Power Sampled (W),Max Power Sampled (W)\n0.1001,1.2856,12.8400,12.8400,12.84,12.84\n```\n\nDemo content of `matrix_power_samples.csv`:\n```text\nTimestamp (ns),Power Draw (W)\n1752198440220994393,12.84\n```\n\n## Dependencies\n\n* Python standard library (`subprocess`, `argparse`, `time`, `csv`)\n* NVIDIA GPU with drivers and `nvidia-smi` tool\n\n## How power and energy are calculated?\n### Power log collection  \nPowerlog 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.\n\n## Total energy consumption computation\n\nTotal energy ***E*** (in Joules) is computed as\n$$\nE = \\sum_{i=1}^N P_i \\cdot \\Delta t_i\n$$\n\nwhere:\n\n- **N**: total number of sampling intervals  \n- **P\u003csub\u003ei\u003c/sub\u003e**: GPU power draw (Watts) at interval *i*  \n- **Δt\u003csub\u003ei\u003c/sub\u003e**: elapsed time (seconds) between sample *i* and sample *i-1*\n\n## Development\n\n### Local Testing\n\nTo test Powerlog locally during development (before releasing to PyPI), you can install your package in \"editable\" mode:\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -e .\n```\n\n### Publishing to PyPI\nWhen the package is ready to publish (or update) Powerlog on PyPI, use the following commands:\n\n```\npython -m pip install --upgrade build\npython3 -m build\npython3 -m pip install --upgrade twine\ntwine upload dist/*\n```\nThis will build the distribution files (.tar.gz and .whl) and upload them to PyPI.\n\nIt requires API token for authentication.\n\n### Changelog\n\nSee the [Changelog.md](Changelog.md) file in this repository for version history and release notes.\n\n## License\n\nMIT License\n\n## Acknowledgments\n\n- Developed as part of GPU power-efficiency profiling experiments in Datalog-based engines.\n- Inspired by the [EUMaster4HPC](https://eumaster4hpc.uni.lu/) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farsho%2Fpowerlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farsho%2Fpowerlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farsho%2Fpowerlog/lists"}