class_docstr: Class for monitoring GPU stats.
code: def __init__(self):
      if "pynvml" not in sys.modules:
          # Only instantiate if `pynvml` is installed.
          raise ImportError(
              "`pynvml` is not installed, to log GPU metrics please run `pip install pynvml` "
              "to install it."
          )
      try:
          # `nvmlInit()` will fail if no GPU is found.
          pynvml.nvmlInit()
      except pynvml.NVMLError as e:
          raise RuntimeError(
              f"Failed to initialize NVML, skip logging GPU metrics: {e}"
          )
  
      super().__init__()
      self.num_gpus = pynvml.nvmlDeviceGetCount()
      self.gpu_handles = [
          pynvml.nvmlDeviceGetHandleByIndex(i)
          for i in range(self.num_gpus)
      ]
  
imports: import logging
  import sys
  from mlflow.system_metrics.metrics.base_metrics_monitor import BaseMetricsMonitor
label_desc: Use image node_id 1 to create a new GPUMonitor object from inherited base classes: BaseMetricsMonitor with example: obj = GPUMonitor()