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

Answer

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

Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .