Skip to main content

Python class

GPUDiagContext

GPUDiagContext

class max.diagnostics.gpu.GPUDiagContext

Context manager providing unified access to GPU diagnostic information across NVIDIA and AMD hardware.

This class automatically detects and initializes supported GPU vendor libraries (NVML for NVIDIA, ROCm SMI for AMD) and provides a unified interface for collecting diagnostic statistics from all available GPUs in the system.

from max.diagnostics.gpu import GPUDiagContext

with GPUDiagContext() as ctx:
    stats = ctx.get_stats()
    for gpu_id, gpu_stats in stats.items():
        print(f"GPU {gpu_id}:  {gpu_stats.memory.used_bytes} bytes used")

get_stats()

get_stats()

Retrieve current GPU statistics for all detected GPUs in the system.

Returns:

A dictionary mapping GPU identifiers to their current statistics. NVIDIA GPUs are prefixed with nv (e.g., nv0, nv1) and AMD GPUs are prefixed with amd (e.g., amd0, amd1).

Return type:

dict[str, GPUStats]