AI绘画——使用stable-diffusion生成图片时提示RuntimeError: CUDA out of memory处理方法

提示显存不足

RuntimeError: CUDA out of memory. Tried to allocate 1.50 GiB (GPU 0; 8.00 GiB total capacity; 5.62 GiB already allocated; 109.75 MiB free; 5.74 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

1、添加参数–n_samples 1,其默认值为3

python scripts/txt2img.py –prompt “a photograph of an astronaut riding a horse” –plms –n_samples 1

AI绘画——使用stable-diffusion生成图片时提示RuntimeError: CUDA out of memory处理方法

; 2、降低精度

修改scripts/txt2img.py文件,在 model.to(device)后添加 .half()

AI绘画——使用stable-diffusion生成图片时提示RuntimeError: CUDA out of memory处理方法

3、结果<

Original: https://blog.csdn.net/PromiseTo/article/details/127240779
Author: PromiseTo
Title: AI绘画——使用stable-diffusion生成图片时提示RuntimeError: CUDA out of memory处理方法

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/647563/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球