Search code examples
pythonpython-3.xrampsutil

Python - Getting Total RAM Size


I need to get total RAM size in gigabytes (e.g. 8 GB or 8.0 GB). It gives as bytes and I convert it into GB by dividing 1024x1024x1024. As a result it gives a number smaller than 8 (e.g. 7.7).

How can I get the size as 8 GB?

NOTE: I have used psutil, free, cat /proc/meminfo, vmstat but result did not change (I will get the terminal output and split it). I do not want to use any external program like dmidecode or lshw.

Python 3.8., OS: Debian-like Linux (x64), Kernel: 4.19

Solution

  • There is no way to get the information you want without digging into the BIOS information, which requires modules you don't have.