CompVis / stable-diffusion

A latent text-to-image diffusion model
https://ommer-lab.com/research/latent-diffusion-models/
Other
66.54k stars 9.97k forks source link

CUDA out of memory. #760

Open fmartinezv966 opened 12 months ago

fmartinezv966 commented 12 months ago

CUDA out of memory. Tried to allocate 5.80 GiB (GPU 0; 14.61 GiB total capacity; 6.54 GiB already allocated; 4.35 GiB free; 9.29 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

henryphz commented 11 months ago

What is your graphics card? Look at this issue:

https://github.com/CompVis/stable-diffusion/issues/86

nautics889 commented 11 months ago

Try to modify txt2img.py (or img2img.py), add calling of .half() when loading your model:

def load_model_from_config(config, ckpt, verbose=False):
    ...

    model.cuda().half()
    ...

Original idea: https://github.com/CompVis/stable-diffusion/issues/86#issuecomment-1230309710