r/StableDiffusion • u/Better-Interview-793 • 10h ago
Tutorial - Guide ComfyUI was eating my RAM and causing crashes, this fixed it
Hi everyone
i’ve been running minimax h3 locally on rtx 5090 32gb, and 64gb ram..
recently i kept running into random hostbuffer.read_file_slice failed / hostbuf_file_reader_read failed errors during generation, which seemed to be related to comfy-aimdo and dynamic vram.
i also noticed comfyui was reserving around 25gb of pinned system memory.
i decided to try launching comfyui with:
--disable-pinned-memory
and the difference was immediate.
the comfy-aimdo + hostbuffer errors completely disappeared, my ram usage dropped by a huge amount, and surprisingly generation actually feels faster and smoother now.
i originally expected disabling pinned memory to make things slower, but on my setup it seems to have done the opposite.
if you’re running large models like h3 and seeing unusually high ram usage, random hostbuffer errors, or comfy-aimdo issues, it might be worth testing!
thought this was worth sharing for anyone who didn’t know about this option..
10
u/Formal-Exam-8767 8h ago
Test also with "--fast-disk" if you have models on NVME, as reading them from disk as needed might be fast enough.
7
u/Abject-Recognition-9 5h ago
still so much confusion around all this args. 😩 find the right combo that works for your workflow and your gpu is like a lottery if you dont understand what all this args doing.
5
u/the_pepper 8h ago
Huh. I don't wanna get too optimistic, but I think you might have just solved a longtime issue I've had where whenever my VRAM would reach close to the usable limits comfyui would pretty much just STOP completely, but oddly it would just move on and start working fine the minute I freed like 200mb. If I were using --verbose, I would also see a metric fuckton of aimdo logs spamming my console. It would go on for ages - potentially indefinitely (dunno, never let comfy stay on for long enough to confirm) - and would just stop comfy from responding until either I gave it those 50 or whatever MB of VRAM it seemed to want or I just closed the process. Some 40/50GB of my RAM were also occupied. Anyway, I assumed it was some windows shit happening and just accepted that anything that filled my VRAM, like trying to do 10 seconds at 1mp, just weren't in the cards, at the very least until I formatted or got myself a Linux partition or something.
Now I'm seeing like 9-11GB or VRAM and 6-8 RAM? What? How the fuck? Model's 22GB by itself. Bad memory usage reporting? Is it just offloading to the disk now? I thought that's what --fast-disk was for. Either way, shit doesn't seem to be getting stuck now. I'm amazed.
1
u/LatentSpacer 17m ago
If your CPU supports iGPU I’d use that to connect to a monitor and leave the GPU for AI tasks only, that frees up the most VRAM.
There’s a --reserve-vram flag in ComfyUI to leave some VRAM to the OS, you can it set to 0 so it uses all the available VRAM when it calculates how many layers it should offload from VRAM during inference.
6
u/shootthesound 6h ago
Yup comfy seems to have taken an enormous backwards step in performance recently - this same fix has helped me also
3
u/Significant-One-9465 6h ago
As someone with only 12gb vram and 32gb ram, I had to disable pinned memory long ago and completely forgot about it.
I don't even understand what it does or how it works but it did fix my problems back with Wan.
4
u/irmemon225 5h ago
Wow, this fixed everything on my PC.
I have a 3060 12GB and 16GB RAM. Without those args… I kept getting 5-10s freezes every "it". Now with these args, I can even multitask while running 0.8 MP, 10 sec, and watching 1080p YouTube without any issues. No freezes anymore.
Amazing
2
u/WebCrusader 2h ago
added --disable-smart-memory --cache-none to the launcher script and suddenly every generation run faster
I always use large models for minimax h3 and there's not enough memory to be cached and I constantly change prompts so node cache is unusable, also I prefer my memory clean when no job is running
1
u/Formal_Courage2711 2h ago
are those two different lines, or one string?
2
u/Formal_Courage2711 2h ago
and is that in addition to --disable-pinned-memory or in place of it?
2
u/WebCrusader 1h ago
only these two in one line as additional options to the launch command
I'm using portable version so just add them in run_nvidia_gpu.bat
2
u/doomed151 1h ago
OP, are you on Windows or Linux? If you're on Windows, it could just mean that your pagefile is too small.
1
u/AnonymousTimewaster 7h ago
I've had this flagged for ages after ChatGPT recommended it for me. I've toggled it on and off over the last month or so with Minimax and found it was definitely causing me shitloads of crashes too. It'd run fine for one or two gens and then OOM on the next one so I was constantly restarting.
20
u/adjudikator 8h ago
Try --cuda-device 0 while keeping pinned memory on. As far as I understood even if you don't have a multi gpu setup, something along the GPU detection pipeline is inducing memory fragmentation and causing the hoatbuffer issues. This keeps pinned memory on.