docstr: Get system statistics and assign to `self`
docstr_tok: ["Get","system","statistics","and","assign","to","`","self","`"]
code: def get_stats(self):
      """
      Get system statistics and assign to `self`
      """
      memory_usage = psutil.virtual_memory()
      disk_usage = psutil.disk_usage("/")
      # net = psutil.net_io_counters()
      system = {
          # CPU utilization percent(can be over 100%)
          "cpu": round10e5(self._process.cpu_percent(0.0)),
          # Whole system memory usage
          # 'memory_used': round10e5(memory_usage.used / 1024 / 1024),
          "memory_percent": round10e5(
              memory_usage.used * 100 / memory_usage.total
          ),
          # Get the portion of memory occupied by a process
          # 'p_memory_rss': round10e5(self._process.memory_info().rss
          #                           / 1024 / 1024),
          "p_memory_percent": round10e5(self._process.memory_percent()),
          # Disk usage
          # 'disk_used': round10e5(disk_usage.used / 1024 / 1024),
          "disk_percent": round10e5(disk_usage.percent),
      }
  
      # Collect GPU statistics
      gpus = []
      try:
          nvml.nvmlInit()
          gpu_device_count = nvml.nvmlDeviceGetCount()
          for i in range(gpu_device_count):
              gpu_info = dict()
              handle = nvml.nvmlDeviceGetHandleByIndex(i)
              try:
                  util = nvml.nvmlDeviceGetUtilizationRates(handle)
                  # GPU utilization percent
                  gpu_info["gpu"] = round10e5(util.gpu)
              except nvml.NVMLError_NotSupported:
                  pass
              try:
                  # Get device memory
                  memory = nvml.nvmlDeviceGetMemoryInfo(handle)
                  # Device memory usage
                  # 'memory_used': round10e5(memory.used / 1024 / 1024),
                  gpu_info["gpu_memory_percent"] = (
                      round10e5(memory.used * 100 / memory.total),
                  )
              except nvml.NVMLError_NotSupported:
                  pass
              try:
                  # Get device temperature
                  nvml_tmp = nvml.NVML_TEMPERATURE_GPU
                  temp = nvml.nvmlDeviceGetTemperature(handle, nvml_tmp)
                  # Device temperature
                  gpu_info["gpu_temp"] = round10e5(temp)
              except nvml.NVMLError_NotSupported:
                  pass
              try:
                  # Compute power usage in watts and percent
                  power_watts = (
                      nvml.nvmlDeviceGetPowerUsage(handle) / 1000
                  )
                  power_cap = nvml.nvmlDeviceGetEnforcedPowerLimit(
                      handle
                  )
                  power_cap_watts = power_cap / 1000
                  power_watts / power_cap_watts * 100
                  # Power usage in watts and percent
                  gpu_info["gpu_power_watts"]: round10e5(power_watts)
                  # gpu_info["power_percent"] = round10e5(power_usage)
              except nvml.NVMLError_NotSupported:
                  pass
              gpus.append(gpu_info)
          nvml.nvmlShutdown()
      except nvml.NVMLError:
          pass
  
      return system, gpus
  
file_path: aim/aim/ext/resource/stat.py
imports: import psutil
  import json
  from typing import List
  from aim.ext.resource.utils import round10e5
  import aim.ext.pynvml
label_desc: Use image node_id 6 for calling the Stat obj's underlying member method code with example usage: obj.get_stats() and returns: system,  gpus