在 AMD GPU 上安装和运行 Stable Diffusion 指南
molivip
编辑于 2023年05月31日 03:40

Windows+AMD尚未正式支持webui, 但你可以安装使用Direct-ml的lshqqytiger的webui分支。

-训练目前不起作用,但各种功能/扩展都可以,例如 LoRA 和控制网。在 https://github.com/lshqqytiger/stable-diffusion-webui-directml/issues 报告问题

  1. 安装 Python 3.10.6 https://www.python.org/ftp/python/3.10.6/python-3.10.6-amd64.exe(勾选添加到 PATH)和 git https://github.com/git-for-windows/git/releases/download/v2.39.2.windows.1/Git-2.39.2-64-bit.exe

  2. CTRL+R 输入CMD,然后将此行粘贴到CMD 中:git clone https://github.com/lshqqytiger/stable-diffusion-webui-directml && cd stable-diffusion-webui-directml && git submodule init && git submodule update

  3. 双击 webui-user.bat  (这个文件默认在【C:\Users\你的用户名】下)

因为网络问题,下载依赖期间会反复报连接错误,如果报错就关闭双击 webui-user.bat 弹出的CMD窗口,重复双击 webui-user.bat ,直到CMD里显示自动下载一个3.7G的模型文件就代表依赖下载完成。

模型下载完成后会显示 Running on local URL:  http://127.0.0.1:7860 

浏览器打开 http://127.0.0.1:7860 

现在点击Generate,如果是4-6G显存的GPU会报显存不足而无法生成图片

这时候,我们要去修改 C:\Users\你的电脑名\stable-diffusion-webui-directml 文件夹下的 webui-user.bat 

用文本编辑器打开 webui-user.bat  ,在 set COMMANDLINE_ARGS=后添加 --opt-sub-quad-attention --medvram --disable-nan-check 使其变成 set COMMANDLINE_ARGS=--opt-sub-quad-attention --medvram --disable-nan-check

(另行说明:实测把 --medvram 换成 --lowvram 可以降低显卡使用率,从99%降低到70%,速度会慢很多,RX580 4g 生成一张 单提示词大小 512x512 的图 --medvram 需要40多秒,--lowvram 则要1分半钟

然后保存

重新双击 webui-user.bat ,启动stable diffusion

————————————————————————————————————————

结束

翻译整理自 https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs