gpu_probe
gpu_probe
¶
GPU probing for the Marianne daemon profiler.
Provides a GpuProbe class that follows the same "try primary → fallback
→ graceful None" pattern as SystemProbe. Priority chain:
- pynvml — NVIDIA Management Library Python bindings (fast, no subprocess)
- nvidia-smi — shell subprocess fallback
- No GPU data — silent skip, returns empty list
All methods are static. _pynvml_available is set once at import time.
Classes¶
GpuMetric
dataclass
¶
Snapshot of a single GPU's current state.
GpuProbe
¶
GPU resource probes following the SystemProbe pattern.
Each method tries pynvml first, then falls back to nvidia-smi. Returns empty list when no GPU is available — callers treat that as "no GPU present" (not an error).
Functions¶
get_gpu_metrics
staticmethod
¶
Get current metrics for all GPUs.
Priority
- pynvml (fast, in-process)
- nvidia-smi subprocess fallback
- Empty list (no GPU / no drivers)
Returns:
| Type | Description |
|---|---|
list[GpuMetric]
|
List of GpuMetric, one per GPU. Empty if no GPU available. |
Source code in src/marianne/daemon/profiler/gpu_probe.py
get_gpu_metrics_async
async
staticmethod
¶
Async variant of get_gpu_metrics.
Uses asyncio.create_subprocess_exec for the nvidia-smi fallback
so it doesn't block the event loop.
Returns:
| Type | Description |
|---|---|
list[GpuMetric]
|
List of GpuMetric, one per GPU. Empty if no GPU available. |
Source code in src/marianne/daemon/profiler/gpu_probe.py
is_available
staticmethod
¶
Check whether any GPU probing method is available.
Returns True if pynvml is importable OR nvidia-smi is on PATH.