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

CUDA out of memory

Open Astraha opened this issue 2 years ago • 4 comments

torch.cuda.OutOfMemoryError: . Tried to allocate 20.00 MiB (GPU 0; 6.00 GiB total capacity; 5.28 GiB already allocated; 0 bytes free; 5.34 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF How can i fix it ?

Astraha avatar Feb 23 '23 22:02 Astraha

Check out https://github.com/CompVis/stable-diffusion/issues/39

wyrde avatar Mar 02 '23 23:03 wyrde

use cpu, or --lowvram, or simply reduce img resolution 🤷🏿

FNsi avatar Mar 06 '23 02:03 FNsi

I ended up using the "optimized" scripts from https://github.com/basujindal/stable-diffusion (I have 6GB of VRAM). The maximum output is ~ 512x512

Shmarkus avatar Apr 21 '23 06:04 Shmarkus

try to use --xformers and use both --lowvram and --medvram

resolution is also a key factor so you can generate image at minimal resolution and upscale it

bhanuj10 avatar Sep 22 '23 17:09 bhanuj10