code: def _get_cpu_memory_info():
      ps_mem_info = namedtuple(
          "ps_mem_info", ["total", "free", "cached", "buffers", "used"]
      )
      try:
          # psutil reads the memory info from /proc/memory_info,
          # which results in returning the host memory instead of
          # that of container.
          # Here we try to read the container memory with method in:
          # https://stackoverflow.com/a/46213331/5163915
          mems = {}
          with open("/sys/fs/cgroup/memory/memory.meminfo", "rb") as f:
              for line in f:
                  fields = line.split()
                  mems[fields[0]] = int(fields[1]) * 1024
          total = mems[b"MemTotal:"]
          free = mems[b"MemFree:"]
          cached = mems[b"Cached:"]
          buffers = mems[b"Buffers:"]
          used = total - free - cached - buffers
          if used < 0:
              used = total - free
          mem_info = ps_mem_info(
              total=total,
              free=free,
              cached=cached,
              buffers=buffers,
              used=used,
          )
      except FileNotFoundError:
          mems = psutil.virtual_memory()
          mem_info = ps_mem_info(
              total=mems.total,
              free=mems.free,
              cached=mems.cached,
              buffers=mems.buffers,
              used=mems.used,
          )
      return mem_info
  
file_path: colossalai/colossalai/legacy/utils/memory.py
imports: import gc
  from collections import namedtuple
  import psutil
  import torch
  import torch.distributed
  from packaging import version
  from colossalai.legacy.core import global_context
  from colossalai.logging import get_dist_logger
  from colossalai.utils import get_current_device
label_desc: Use image node_id 2 for calling a global function with example usage: _get_cpu_memory_info() and returns: mem_info