Categories
dev Linux

Low Linux memory

Spent enough time on this to warrant a note.

For some reason, pip install torch, which is what I was trying to do, kept dying. It’s a 700MB file, and top showed out of memory.

Ultimately the fix for that was:

pip install torch --no-cache-dir

(something was wrong with the cache I guess)

I also ended up deleting the contents of ~/.cache/pip which was 2.2GB. The new pip cache purge only clears wheels related libs.

Anyway, trying to do development on a 23GB chromebook with GalliumOS gets tough.

I spend a lot of time moving things around. I got myself an NVMe SSD, with 512GB to alleviate the situation.

The most common trick for looking at memory is df -h for seeing memory use, and du -h --max-depth=1 to see how big the directories are, below your current dir.

So, first thing first, the SSD doesn’t want to show up. Ah, the USB-C wasn’t pushed in all the way. Derp.

Second, to clear up some space, linux has journal logs.

https://unix.stackexchange.com/questions/139513/how-to-clear-journalctl :

set a max amount of logs to retain (by time/space):
journalctl --vacuum-time=2d
journalctl --vacuum-size=500M

The third thing is to make some more swap space, just in case.

touch /media/chrx/0FEC49A4317DA4DA/swapfile
cd /media/chrx/0FEC49A4317DA4DA/
sudo dd if=/dev/zero of=swapfile bs=2048 count=1048576
mkswap swapfile
swapon swapfile

swapon

NAME                          TYPE           SIZE   USED PRIO
/dev/zram0                    partition      5.6G 452.9M -2
/media/chrx/0FEC49A4317DA4DA/ swapfile file  2G       0B -3

Ok probably didn’t need more swap space. Not sure where /dev/zram0 is, but maybe I can free up more of it, and up the priority of the SSD?

Anyway, torch is installed now, so nevermind, until I need more memory.

Some more tricks:

Remove thumbnails:

du -sh ~/.cache/thumbnails

rm -rf ~/.cache/thumbnails/*

Clean apt cache:

sudo apt-get clean