Skip to main content

A package to fetch GPU stats on macOS using powermetrics

Project description

macgputils

macgputils is a lightweight Python utility to fetch GPU statistics on macOS using the native powermetrics tool. It provides programmatic access to GPU power usage, frequency, active/idle time, and more.

Features

  • Read real-time GPU power consumption (in mW)
  • Get GPU hardware active frequency
  • Check GPU idle residency
  • Sample multiple times to monitor changes over time
  • Easy-to-use API: macgputils.get_gpu_stats()

Installation

pip install macgputils

If powermetrics is not already available, macgputils will prompt and help install it via Apple's developer tools.

Usage

import macgputils

# Get single sample
stats = macgputils.get_gpu_stats()
print(stats)

# Get multiple samples
for sample in macgputils.get_gpu_stats(samples=3):
    print(sample)

Output Example

{'Active Frequency': '389 MHz', 'HW Active Residency': '14.00%', 'Idle Residency': '86.00%', 'GPU Power': '33 mW'}

API Reference

macgputils.get_gpu_stats(samples=1, interval=5)

Parameter Description
samples Number of GPU usage samples to collect
interval Time in seconds between each sample

Returns:

  • A dictionary if samples=1
  • A list of dictionaries if samples > 1

Requirements

  • macOS
  • Python 3.6+
  • powermetrics (part of macOS; auto-installable via Xcode command line tools)

License

MIT License


Author

Developed by @aabhinavg1. Contributions are welcome — feel free to fork and submit pull requests!

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

macgputils-0.1.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

macgputils-0.1.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file macgputils-0.1.2.tar.gz.

File metadata

  • Download URL: macgputils-0.1.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for macgputils-0.1.2.tar.gz
Algorithm Hash digest
SHA256 46e46e695fefc55abe7b128f0acbcf828d7a67ebb515e57cef4ba01e7e78a114
MD5 365e3192de15706f61e1c76ca6e10a16
BLAKE2b-256 2d6148c192be1ebf080f5f3fa974bc603cb673ca53b522d5d4146e1210547684

See more details on using hashes here.

File details

Details for the file macgputils-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: macgputils-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for macgputils-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35fbe54f44f5259963e0862a17a9ee2bf7c94526db0bcdf22866305dd9c87791
MD5 78878dd665b1b3440870388c3677aff1
BLAKE2b-256 28ccc3dd6c25bde7211c92fad32af068a7b8f84a2278e469db217a1de37152bd

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