提示显存不足
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()


当使用stable-diffusion进行AI绘画时遇到CUDA内存不足的问题,可以通过设置--n_samples 1降低采样数,或者修改代码降低精度来缓解。此外,可以尝试使用stable-diffusion-webui以半精度运行模型,减少GPU内存需求。项目地址:https://github.com/AUTOMATIC1111/stable-diffusion-webui
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



