Skip to main content

Unified GPU telemetry for Apple Silicon, NVIDIA, and beyond

Project description

gpulegion

Unified GPU telemetry for Apple Silicon, NVIDIA, and beyond.

PyPI version Python 3.9+

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 names
  • is_available() → True if GPU monitoring is supported
  • usage() → GPU utilization percentage (0-100) or None
  • power() → GPU power consumption in watts or None
  • memory() → Dict with used_mb and total_mb or None
  • device() → Dict with vendor, model, and device info or None

Design Philosophy

  • Never crash: Returns None when 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpulegion-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

gpulegion-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

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

Hashes for gpulegion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 72de6d55558468c3ada39b760e34beabe2642883dc80ff4edb508b285980c643
MD5 7a539dd897d322f36615e94ed86eac75
BLAKE2b-256 2923463635f904f43913d0332af0de28ce95a1b36115f0f9b352dc77ce38a6a3

See more details on using hashes here.

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

Hashes for gpulegion-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c58de7196e149abac24b3ae111a97690af5922077694f094c8487b6dc990d6e
MD5 3feff7d6c705cfaa364db964cd53fe3d
BLAKE2b-256 b14419ff9d18cd40ade7c73e24230285d8728486bf7e5a57579ce74f43b84147

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