blob: c111a9074c1582a37793bbccfc49c4a2d2384f6d [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001#!/usr/bin/env python3
2# https://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python/28161352
3import sys
4meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines())
5mem_free = meminfo['MemTotal']/1024./1024.
6if mem_free < 2.:
7 raise RuntimeError("Insufficient free memory({:.3f}): requires > 2 GB".format(mem_free))
8 sys.exit(1)
9else:
10 print("Free memory: {:.3f} GB".format(mem_free))