def get_system_total_memory_gb():
 import os
 import sys
 if (u'linux' in sys.platform):
  with open(u'/proc/meminfo', u'r') as f_in:
   meminfo_lines = f_in.readlines()
   mem_total_line = [line for line in meminfo_lines if (u'MemTotal' in line)][0]
   mem_total = float(mem_total_line.split()[1])
   memory_gb = (mem_total / (1024.0 ** 2))
 elif (u'darwin' in sys.platform):
  mem_str = os.popen(u'sysctl hw.memsize').read().strip().split(u' ')[(-1)]
  memory_gb = (float(mem_str) / (1024.0 ** 3))
 else:
  err_msg = u'System platform: %s is not supported'
  raise Exception(err_msg)
 return memory_gb

def get_system_total_memory_gb ( ) : import os import sys if ( u'linux' in sys . platform ) : with open ( u'/proc/meminfo' , u'r' ) as f_in : meminfo_lines = f_in . readlines ( ) mem_total_line = [ line for line in meminfo_lines if ( u'MemTotal' in line ) ] [ 0 ] mem_total = float ( mem_total_line . split ( ) [ 1 ] ) memory_gb = ( mem_total / ( 1024.0 ** 2 ) ) elif ( u'darwin' in sys . platform ) : mem_str = os . popen ( u'sysctl hw.memsize' ) . read ( ) . strip ( ) . split ( u' ' ) [ ( - 1 ) ] memory_gb = ( float ( mem_str ) / ( 1024.0 ** 3 ) ) else : err_msg = u'System platform: %s is not supported' raise Exception ( err_msg ) return memory_gb
function to get the total ram of the running system in gb .