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

在这里插入图片描述

2、降低精度

修改scripts/txt2img.py文件,在model.to(device)后添加.half()
在这里插入图片描述

3、结果<

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年3月2日 下午10:52
下一篇 2023年3月3日 下午9:00

相关推荐