导航

本地部署stable-diffusion-webui出现的问题记录

Posted on 2023-04-19 15:25  蝈蝈俊  阅读(942)  评论(1编辑  收藏  举报

如果你想本机运行 Stable Diffusion 画图,stable-diffusion-webui 可能是最佳选择之一。

安装配置它的过程看 https://github.com/AUTOMATIC1111/stable-diffusion-webui 页的Installation and Running部分。

我是在2015年的MacBook Pro本上(Intel Core i7)安装的,碰到下面几个问题:

Couldn't install gfpgan

这个错误是:无法下载 GitHub 的源码,我们可以通过 ghproxy.com 代理下访问 GitHub。其他类似 Couldn't install XXX 的报错应该都是这个原因。

ghproxy 是一个 GitHub 代理加速服务,它可以帮助您快速下载 GitHub 上的文件。

具体操作步骤:

  1. 在你的 stable-diffusion 主目录,找到 launch.py 文件。

  2. 修改 prepare_environment 函数,在每个  https://github.com/  开头的链接前面添加   https://ghproxy.com/   ,变成如下图所示的  https://ghproxy.com/https://github.com/  格式开头。

注意所有都要修改。

  1. 保存后,再去运行 ./webui.sh 即可。

参考:
https://www.bilibili.com/read/cv19991459

RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'

除了 CUDA 以外的 PyTorch 都不支持半精度,所以每次运行时都要加一些 flags。

我这里由于笔记本老,又增加了其他一些参数:
我这里是 Mac 的,修改的是 webui-user.sh 文件, Win 的是修改 webui-user.bat 文件


export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half"

  • -–skip-torch-cuda-test:这个参数是用来跳过检测 torch 是否能使用 GPU 的,如果您的 CUDA 和 torch 版本不匹配,或者您的电脑没有 CUDA GPU ,可以使用这个参数来绕过这个检测。

  • -–precision full:这个参数是用来指定 torch使用全精度(32位)的浮点数来运算的,相比于半精度(16位)或混合精度(16位和32位),全精度可以提高运算的准确性,但也会增加运算的时间和内存消耗。

  • -–no-half:这个参数是用来禁止 torch 使用半精度的数据类型的,如果您的显卡不支持半精度,或者您遇到了 "LayerNormKernelImpl" not implemented for ‘Half’ 的错误,可以使用这个参数来解决。

参考:https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/5232

其它参考资料

修改了上面,应该就可以运行了,下面给一个 Prompt。

masterpiece, best quality, 1girl, white and green hair, red buttons, blue hair, short hair, ahoge, transparent sleeves, light smile, ocean, firework, incredibly absurdres, artbook
Negative prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry
Steps: 24, Sampler: DDIM, CFG scale: 11, Seed: 1594337505, Size: 512x512, Model hash: ab21ba3c

生成效果:

参考: AI绘画指南 stable diffusion webui如何设置与使用