code: def print_gpu_memory_usage():
      """
      Parse the nvidia-smi output and extract the memory used stats.
      Not recommended to use.
      """
      sp = subprocess.Popen(
          ["nvidia-smi", "--query-gpu=memory.used", "--format=csv"],
          stdout=subprocess.PIPE,
          stderr=subprocess.PIPE,
          close_fds=True,
      )
      out_str = sp.communicate()
      out_list = out_str[0].decode("utf-8").split("\n")
      all_values, count, out_dict = [], 0, {}
      for item in out_list:
          if " MiB" in item:
              out_dict[f"GPU {count}"] = item.strip()
              all_values.append(int(item.split(" ")[0]))
              count += 1
      logging.info(
          f"Memory usage stats:\n"
          f"Per GPU mem used: {out_dict}\n"
          f"nMax memory used: {max(all_values)}"
      )
  
file_path: vissl/vissl/utils/logger.py
imports: import atexit
  import functools
  import logging
  import subprocess
  import sys
  from iopath.common.file_io import g_pathmgr
  from vissl.utils.io import makedir
label_desc: Use image node_id 5 for calling a global function with example usage: print_gpu_memory_usage() without return types