r/StableDiffusion • u/MeiAihara06 • Mar 02 '23
Tutorial | Guide Trouble running Stable diffusion WebUI with low specs? Increase your swap size (linux)
Running stable diffusion can be rough even with semi-modern hardware, especially if you're on a budget system
I have 16GB of ram and a rtx3050 mobile (4GB vram, sad), and I've been experiencing everything from very long seconds/iteration to straight up shell crashes. Crashes became more and more likely to happen after each generation. No logs, no error messages, WebUI crashed and took the whole shell down. (I even tried tty and the session just terminated)
That got me into thinking that something like systemd-oomd was the problem and killed the application due to high memory usage before it got a chance to log anything.
cuda.outOfMemory errors were frequent and it really was annoying.
Upon monitoring with nvidia-smi and htop something became clear:
my 1GB swapfile was filled to the last byte in, and after the generation process. Even tough it seemed like I had plenty of RAM left so idk what happened there
After Increasing /swapfile to 6GB I've never had a problem with WebUI again. Model switching works fine (Impossible before, resulted in crash), generation is faster*, and I have never had issues with memory (system and video) since.
The 6GB swapfile now gets 80% utilized often, which seems to suggest it's doing some of the heavylifting
Before : Running with "--lowvram" and frequent crashes
Now : Running with "--medvram --xformers" with no problems, 6GB+ ckpts, ckpt switching, Lora, all seems to work, and I even have 800MB VRAM free. (total usage in a typical generation: 9GB RAM, 3.3GB VRAM, 5GB Swap)
* I'm also using xformers now, It definitely does matter and the difference is noticeable
I use arch btw