Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 675
demirod Avatar asked Jun 06 '26 20:06

demirod


1 Answers

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

like image 137
Tim Roberts Avatar answered Jun 08 '26 10:06

Tim Roberts