Unified GPU telemetry for Apple Silicon, NVIDIA, and beyond
Project description
gpulegion
Unified GPU telemetry for Apple Silicon, NVIDIA, and beyond.
Why gpulegion?
Existing Python GPU monitoring tools like GPUtil only support NVIDIA GPUs. If you're developing on Apple Silicon (M1-M5), you're out of luck.
gpulegion fills that gap with a simple, cross-platform API:
| Tool | Apple Silicon | NVIDIA | Programmatic API |
|---|---|---|---|
| GPUtil | ❌ | ✅ | ✅ |
| gputop | ❌ | ✅ | ⚠️ (CLI-first) |
| gpulegion | ✅ | ✅ | ✅ |
Installation
pip install gpulegion
Quick Start
import gpulegion as gl
# Check if GPU monitoring is available
if gl.is_available():
print(f"GPU Usage: {gl.usage()}%")
print(f"GPU Power: {gl.power()}W")
print(f"Device: {gl.device()}")
else:
print("No GPU detected")
API Reference
Core Functions
backends()→ List of available backend namesis_available()→ True if GPU monitoring is supportedusage()→ GPU utilization percentage (0-100) or Nonepower()→ GPU power consumption in watts or Nonememory()→ Dict withused_mbandtotal_mbor Nonedevice()→ Dict with vendor, model, and device info or None
Design Philosophy
- Never crash: Returns
Nonewhen data unavailable - Minimal dependencies: No heavy ML frameworks required
- Cross-platform: Works on macOS (Apple Silicon), Linux (NVIDIA), and gracefully degrades elsewhere
Platform Support
Apple Silicon (M1-M5)
Requires passwordless sudo access to powermetrics:
# Add to /etc/sudoers.d/powermetrics
your_username ALL=(ALL) NOPASSWD: /usr/bin/powermetrics
NVIDIA
Requires nvidia-smi (comes with NVIDIA drivers).
Example Output
>>> import gpulegion as gl
>>> gl.device()
{'vendor': 'Apple', 'model': 'Apple M2 Pro', 'arch': 'arm64'}
>>> gl.usage()
34.2
>>> gl.power()
12.8
Roadmap
- Apple Silicon support
- NVIDIA support
- AMD support
- Intel discrete GPU support
- Multi-GPU support
- CLI tool
Contributing
Contributions welcome! This library is intentionally minimal - we prioritize reliability over features.
License
MIT
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 gpulegion-0.1.1.tar.gz.
File metadata
- Download URL: gpulegion-0.1.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72de6d55558468c3ada39b760e34beabe2642883dc80ff4edb508b285980c643
|
|
| MD5 |
7a539dd897d322f36615e94ed86eac75
|
|
| BLAKE2b-256 |
2923463635f904f43913d0332af0de28ce95a1b36115f0f9b352dc77ce38a6a3
|
File details
Details for the file gpulegion-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gpulegion-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c58de7196e149abac24b3ae111a97690af5922077694f094c8487b6dc990d6e
|
|
| MD5 |
3feff7d6c705cfaa364db964cd53fe3d
|
|
| BLAKE2b-256 |
b14419ff9d18cd40ade7c73e24230285d8728486bf7e5a57579ce74f43b84147
|