stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: SD freezing PC after I changed model

Open Nelaryn opened this issue 2 years ago • 17 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

Hello,

Before you read I apologize for the messy presentation and lack of information. I have no background in programming so I have no idea what would be the correct way to define my issue.

I wanted to try out more models and upon switching the checkpoint top-left it was stuck on Loading for a long time. I've tried restarting the webui.bat since that used to work in the past as it loaded in the model for me in case it took so long, however this time it just froze my PC entirely. This happened already once however at the time using git pull to update SD helped the issue but that's not an option since I have the latest version and I'd like to use more models in general.

freeze

Freeze happens shortly after the line "Commit hash: ...." appears.

I've tried removing --medvram as well in case that's what caused the issue but it also didn't work. One curious thing to note is that when I took the screenshot before my PC froze for some reason instead of 1920x1080 it was 1920x2536 but the space beneath was empty. This could be completely irrelevant, however it only happens when I run the bat and while sd operates normally screenshots are also taken correctly.

If anyone could point me to the right direction with this one that would be appreciated. I have a lot of fun using SD and got no clue on how to fix this.

Steps to reproduce the problem

  1. Go to .... Top left on SD
  2. Press .... The checkpoint to load another model
  3. ... Wait for 10-20 minutes to fail loading it
  4. ... Start crashing when you try to restart webui.bat

What should have happened?

SD should've started without freezing my PC

Commit where the problem happens

b165e341e70300f66c8a77b9383041f4147b24a8

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

only added and removed --mmedvram

Additional information, context and logs

No response

Nelaryn avatar Jan 20 '23 08:01 Nelaryn

Try increasing the page file size in windows. You are likely running out of ram. Do you use a disk drive or solid state? You can watch ram usage from task manager.

ClashSAN avatar Jan 20 '23 08:01 ClashSAN

Try increasing the page file size in windows. You are likely running out of ram. Do you use a disk drive or solid state? You can watch ram usage from task manager.

I installed it on my HDD, however, I haven't had this issue before. Got 16 GB of ram and I have allocated 8 GB of page file on my SSD already.

Nelaryn avatar Jan 20 '23 09:01 Nelaryn

I also have the same problem on linux, I have 32GB RAM, and after changing models 2-3 times, I also run out of all swap

DanielusG avatar Jan 20 '23 11:01 DanielusG

I also have the same problem on linux, I have 32GB RAM, and after changing models 2-3 times, I also run out of all swap

Similar thing on Colab, using any of the known notebooks for the webui. Seems like a memory leak. This issue, strangly enough, also affects Aadnk's whisper-webui. Same deal there, Whisper model loads, system ram isn't freed, switch models, even more system ram isn't freed, inevitable ^C or CUDA OOM. I think it has to do with a regression in PyTorch (Or one of the dependencies of it), since that's the one thing both this and that share in common.

Daviljoe193 avatar Jan 20 '23 14:01 Daviljoe193

Have been looking into this, but might not be an issue anymore? On linux, at least on the latest commit and with either PyTorch 1.13 or PyTorch 2.0 both don't seem to have a problem and are freeing the memory properly.

atensity avatar Jan 23 '23 18:01 atensity

Have been looking into this, but might not be an issue anymore? On linux, at least on the latest commit and with either PyTorch 1.13 or PyTorch 2.0 both don't seem to have a problem and are freeing the memory properly.

Nothing has changed for me on Colab.

stillhappenes

Daviljoe193 avatar Jan 24 '23 00:01 Daviljoe193

Have been looking into this, but might not be an issue anymore? On linux, at least on the latest commit and with either PyTorch 1.13 or PyTorch 2.0 both don't seem to have a problem and are freeing the memory properly.

Nothing has changed for me on Colab.

stillhappenes

A few weeks ago, when I was also running AUTOMATIC1111 on Colab, the RAM usage was about 2.5GB - 4GB Now many times the machine stops / restarts due to insufficient RAM :(

So I am forced to use my laptop with the 2060, but it has only 6GB of VRAM and they run out quickly

DanielusG avatar Jan 24 '23 08:01 DanielusG

Disable caching of models Settings > Stable Diffusion > Checkpoints to cache in RAM - 0

I find even 16 GB isn't enough when you start swapping models both with Automatic1111 and InvokeAI

Aamir3d avatar Jan 24 '23 17:01 Aamir3d

Disable caching of models Settings > Stable Diffusion > Checkpoints to cache in RAM - 0

I find even 16 GB isn't enough when you start swapping models both with Automatic1111 and InvokeAI

Checkpoint caching is already set to 0 by default, so likely that's not what's causing the issue.

Daviljoe193 avatar Jan 24 '23 21:01 Daviljoe193

Disable caching of models Settings > Stable Diffusion > Checkpoints to cache in RAM - 0 I find even 16 GB isn't enough when you start swapping models both with Automatic1111 and InvokeAI

Checkpoint caching is already set to 0 by default, so likely that's not what's causing the issue.

Thanks @Daviljoe193

I was responding to OP @Nelaryn here When running SD Locally, it uses a lot of RAM and there's a lot of paging before it loads the checkpoint into memory. If there are multiple applications open (Chrome as an example), I've seen my system grind to a halt too. The solution that worked with 16GB is to enable the model change, and exit chrome, and then start Chrome again after the model is loaded.

I found this happened both with InvokeAI and Automatic1111. The easy fix was to upgrade to more RAM :-)

@Daviljoe193 Your issue might be different in that Colab isn't releasing RAM

Aamir3d avatar Jan 24 '23 22:01 Aamir3d

Disable caching of models Settings > Stable Diffusion > Checkpoints to cache in RAM - 0 I find even 16 GB isn't enough when you start swapping models both with Automatic1111 and InvokeAI

Checkpoint caching is already set to 0 by default, so likely that's not what's causing the issue.

Thanks @Daviljoe193

I was responding to OP @Nelaryn here When running SD Locally, it uses a lot of RAM and there's a lot of paging before it loads the checkpoint into memory. If there are multiple applications open (Chrome as an example), I've seen my system grind to a halt too. The solution that worked with 16GB is to enable the model change, and exit chrome, and then start Chrome again after the model is loaded.

I found this happened both with InvokeAI and Automatic1111. The easy fix was to upgrade to more RAM :-)

@Daviljoe193 Your issue might be different in that Colab isn't releasing RAM

but i have 32gb ram in my laptop, the first 2-3 models i can load it, when i continue it finishes also the swap and linux some times it kills the graphical session and it restarts linux :(

DanielusG avatar Jan 25 '23 12:01 DanielusG

Potentially a duplicate of https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2180

jchook avatar Jan 27 '23 00:01 jchook

Disable caching of models Settings > Stable Diffusion > Checkpoints to cache in RAM - 0 I find even 16 GB isn't enough when you start swapping models both with Automatic1111 and InvokeAI

Checkpoint caching is already set to 0 by default, so likely that's not what's causing the issue.

Thanks @Daviljoe193

I was responding to OP @Nelaryn here When running SD Locally, it uses a lot of RAM and there's a lot of paging before it loads the checkpoint into memory. If there are multiple applications open (Chrome as an example), I've seen my system grind to a halt too. The solution that worked with 16GB is to enable the model change, and exit chrome, and then start Chrome again after the model is loaded.

I found this happened both with InvokeAI and Automatic1111. The easy fix was to upgrade to more RAM :-)

@Daviljoe193 Your issue might be different in that Colab isn't releasing RAM

I'll give it a shot, however it's weird that this hasn't happened before and I was able to freely switch between models.

Nelaryn avatar Feb 05 '23 17:02 Nelaryn

same problem on arch linux

linsyking avatar Mar 18 '23 12:03 linsyking

same issue, running on linux ubuntu 20.04, inside docker container

iumyidol avatar Apr 06 '23 08:04 iumyidol

Experiencing this on Ubuntu as well

neural-loop avatar Apr 07 '23 23:04 neural-loop

Same problem , using AMD card on arch linux.

mafteiosul avatar Apr 19 '23 13:04 mafteiosul

Commenting here cause the problem is persistent.

mockinbirdy avatar May 30 '23 18:05 mockinbirdy

This bug seems fixed for me when I have enabled tmalloc.

I'm using https://github.com/jchook/stable-diffusion-webui-docker

The relevant Dockerfile lines:

  • https://github.com/jchook/stable-diffusion-webui-docker/blob/a37f589c107449f6009348d04e2f9eb6b7014986/Dockerfile#L19
  • https://github.com/jchook/stable-diffusion-webui-docker/blob/a37f589c107449f6009348d04e2f9eb6b7014986/Dockerfile#L61

jchook avatar Jun 06 '23 02:06 jchook