Massive RAM consuming since recent commits #5094
Replies: 14 comments 20 replies
-
How much specifically? Mine was and still is eating ~11 gigs of RAM, and up to 30 on generation of big depth maps on CPU. |
Beta Was this translation helpful? Give feedback.
-
@aliencaocao Because this might be a potential answer, I pull it out from nested reply for clearer reference. My cache in ram setting is 0, because the models is too large for my 16G RAM to handle (And I rarely use more than one model in one session). |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Currently I see the RAM consumption differs from sampler to sampler, both according to my tests and others', so this might be related to one of the sampler changes among recent commits. |
Beta Was this translation helpful? Give feedback.
-
It's 2024 and I'm experiencing this too. I have 64GB of RAM and an RTX 4090..... and this eats literally all of my RAM, then fills up all of the swap, crashing my computer after several rounds of generation. It seems the cache limit isn't being respected as the data is essentially lingering like OP said. This is generally known as a memory leak. |
Beta Was this translation helpful? Give feedback.
-
I've experienced this as well, seemingly all of the sudden. As it turned out, upgrading torch for good measure when getting the latest WebUI release was not a good idea. From what I observed on my system, it seemed like some sort of garbage collection wasn't kicking in properly every now and then? And it seemed to be connected to --medvram-sdxl to some extent (didn't observe high usage without, but also can't actually generate SDXL without it). Sometimes it cleaned up after generation and it went fine, but it'd often fail and such take up all system RAM (32 GB in my case) + roll the dice between crashing just python or take the GPU driver with it (sounds unrelated but happened a few times). I don't know what triggers this specifically, but I downgraded to torch 2.0.1, torchvision 0.15.2, xformers 0.0.20 and the issues were gone. Versioning warnings aside, everything seems to be working. As I also experienced the same behavior in WebUI Forge, I'm not sure if this is something to fix in WebUI itself. But I also don't feel knowledgeable enough of the ecosystem to make a useful report on upstream torch if the issue lies there. So for now I'll just leave this info here for anyone else affected. Happy to be corrected if some of this is factually wrong, but I went through venv reinstalls, WebUI downgrades, etc. and only this helped me. |
Beta Was this translation helpful? Give feedback.
-
I can confirm that the latest version (1.8.0) is much slower for me and takes more RAM. It eats all my 16 Gb and make the whole computer lag. With the previous version, I was able to use other apps during generation. First, I used the version 1.7.0 and then I upgraded to 1.8.0 using simply a "git pull". As suggested in the console window, I upgraded PyTorch to version 2.1.2 and started experiencing the high RAM usage. So I decided to revert to the previous version using :
This command only affects the repository, not the VENV and any dependencies, the PyTorch is still 2.1.2 at this point. And launching webui-user as usual worked as expected at the same speed as before. My guess is that the cause of this issue is not PyTorch itself, maybe the way it's called. To reproduce this installation, I deleted everything and started from scratch
Maybe this helps. I started looking at the source code if I see something. Otherwise, I will continue with version 1.7.0 as it works well. |
Beta Was this translation helpful? Give feedback.
-
I had this problem after upgrading to 1.9.0, no problem with 1.8.0. |
Beta Was this translation helpful? Give feedback.
-
+1'ing. Upgrading from 1.8.0 more than quadrupled my RAM use. Will ramp itself up to 16-20GB on a 2GB 1.5 model and not release unless task killed. Win 10, 3080 10G, 32GB RAM |
Beta Was this translation helpful? Give feedback.
-
So this issue is almost 2 years old. Doubt it'll get fixed Just starting up A1111 takes 3.5gb. After that it's all down hill till it crashes. Great job |
Beta Was this translation helpful? Give feedback.
-
+1 I hope someone figures something out, this is getting really irritating. Downgrading for me isn't much of an option for me specifically so I am kinda hoping for some kind of fix... |
Beta Was this translation helpful? Give feedback.
-
Any of you by chance using Ultimate SD Upscale? Because that's where my problems started. Switched over to the normal SD Upscale, and RAM usage is way down |
Beta Was this translation helpful? Give feedback.
-
I tried to upgrade to 1.9.3 and I was expecting the same behavior as 1.8.0. And I can't explain why but it seems to be better. The RAM usage is still high sometimes, compared to 1.7.0, but a bit less than 1.8.0. And I can use SDXL and ControlNet now. What I tried also are some performance tips such as disabling the hardware acceleration in browser, and setting to maximum performance in NVIDIA configuration (also, check your configuration if using a laptop, make sure it's not running on battery and disable any power saving feature). Also, what I have done, to avoid any slowdown caused by browser, is to use Automatic1111 in API mode (with the command line parameter --api), and created some Python scripts to make the query directly. This saves RAM and can increase performance. Below is one of my scripts. Generates 1920x1080 picture with SDXL if someone is interested. Reference here : https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API import requests
import base64
# Define the URL and the payload to send.
url = 'http://127.0.0.1:7860'
prompt = '(fantasy castle floating on a cloud), blue sky, photography, best quality'
negative_prompt = '2D, illustration, low quality, blurry'
payload = {
"scheduler": "Automatic",
"prompt": prompt,
"negative_prompt" : negative_prompt,
"width": 960,
"height": 540,
"steps": 20,
"denoising_strength": 0.7,
"sampler_name": "DPM++ 2M",
"enable_hr": True,
"hr_scale": 2,
"hr_resize_x": 0,
"hr_resize_y": 0,
"hr_second_pass_steps": 0,
"hr_prompt": prompt,
"hr_negative_prompt": negative_prompt,
"hr_upscaler": "Latent",
"Tiled VAE": {"args": [True, 1024, 64, True, True, True, False]},
"send_images": False,
"save_images": True
}
# Send said payload to said URL through the API.
response = requests.post(url=f'{url}/sdapi/v1/txt2img', json=payload)
r = response.json() |
Beta Was this translation helpful? Give feedback.
-
All right so, i know very little about AI and all, had this massive ram deal too, today fidgeting around, found a settings menu for wsl 2 (im using docker) so one of the settings let me reasing the max amount of ram it could use, well for my machine it had 16 gigs by default, maybe its this wsl 2 thing causing the massive ram comsumption |
Beta Was this translation helpful? Give feedback.
-
I started playing with the sd webui since a couple of months ago. At that time, after the huge consumption of RAM at the start-up, which is to load the weights in the models, the RAM consumption typically stay nice and low even if you start generating images with it. So I can easily use other applications with it running in the background.
However recently, the webui starts to consume a lot of RAM after the start up, and it usually start to do so after one round of image generation. Afterwards, it doesn't release the memory so the consumption stays high, severely impacting the performance of my pc on other applications.
The question I'd like to ask is mainly just a reason. I am not quite sure why this would be the case, and whether it is me that is doing something wrong, like improper settings, or it is some recent features that are contributing to this problem. I don't understand why it would happen otherwise because the previous versions don't have this problem.
I run my webui with xformers and deepdanbooru, and the ddb is correctly set to using gpu, for I can observe the correct register info in the starting up messages.
Beta Was this translation helpful? Give feedback.
All reactions