pip install memory_profiler
from memory_profiler import memory_usage mem_usage = memory_usage(-1, interval=1, timeout=1) print(mem_usage)