Skip to content

在 Intel Silicon 上安装并运行

Stable Diffusion WebUI 支持(预览)

现在,使用英特尔® Distribution of OpenVINO™工具包,可以在英特尔CPU和GPU(集成和独立图形)等硬件上运行Stable Diffusion WebUI 。这是积极发展的预览支持,我们积极欢迎社区的反馈和贡献。

重要注意事项

为了在Windows上实现WebUI的最佳性能,请使用以下步骤启动webui-user.bat:

  • 以管理员身份启动命令提示符
  • cd到 stable-diffusion-webui 目录
  • 运行webui-user.bat

OpenVINO加速脚本目前不支持某些功能:

  • 雇佣修复
  • 自定义脚本
  • 带有SD v1.5的768x768

使用OpenVINO运行WebUI的说明:

OpenVINO支持通过自定义脚本提供。自定义脚本使用PyTorch的torch.compile功能和HuggingFace Diffusers库来提高性能。以下是入门说明:

  • 如果您熟悉Automatic1111工作流程,请使用OpenVINOToolKit的此分支而不是Automatic1111,并按照说明操作。或者,按照以下说明操作:

Linux

## Make sure Python version is 3.10+
python -m venv sd_env
source sd_env/bin/activate
git clone https://github.com/openvinotoolkit/stable-diffusion-webui.git
cd stable-diffusion-webui

export PYTORCH_TRACING_MODE=TORCHFX
export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half --listen --share" 

## Launch the WebUI
./webui.sh 

  • 通过运行./webui.sh启动WebUI后,按照此处的说明使用OpenVINO自定义脚本

窗口

git clone https://github.com/openvinotoolkit/stable-diffusion-webui.git
cd stable-diffusion-webui
  • stable-diffusion-webui目录中,更新webui-user.bat文件,使其看起来像下面
@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--skip-torch-cuda-test --precision full --no-half
set PYTORCH_TRACING_MODE=TORCHFX

call webui.bat
  • 通过运行webui-user.bat首次启动WebUI。它应该安装先决条件。
  • 完成所有先决条件的安装后,使用CTRL+C终止WebUI。
  • --skip-prepare-environment参数添加到webui-user.bat文件中的COMMANDLINE_ARGS变量中。要从远程机器通过公共URL访问WebUI,请向COMMANDLINE_ARGS添加其他参数"--listen --share"
  • 按照此处的说明安装额外的先决条件
  • 通过运行再次启动WebUIwebui-user.bat
  • 按照此处的说明使用OpenVINO自定义脚本

安装说明

先决条件

PyTorch

OpenVINO作为TarchDynamo后端集成在PyTorch中,可以使用“torch.compile”进行利用。TorchDynamo从PyTorch 2.0开始提供。

Linux:

使用从PyPi安装PyTorchpip install torch

窗户:

PyTorch尚未在Windows上正式支持torch.compile。然而,以下变通方法可用于利用Windows上的torch.compile功能:

  • 从这里安装经过验证的PyTorch夜间轮文件(2.1.0.dev20230713)
  • 在venv/Lib/site-packages/torch/_dynamo/eval_frames.py上更新文件
  • 找到名为“check_if_dynamo_supported()”的函数,它看起来像这样(第484行):
def check_if_dynamo_supported():
    if sys.platform == "win32":
        raise RuntimeError("Windows not yet supported for torch.compile")
    if sys.version_info >= (3, 11):
        raise RuntimeError("Python 3.11+ not yet supported for torch.compile")
  • 注释出此功能的前两行。它应该看起来像这样:
def check_if_dynamo_supported():
    # if sys.platform == "win32":
    #    raise RuntimeError("Windows not yet supported for torch.compile")
    if sys.version_info >= (3, 11):
        `raise RuntimeError("Python 3.11+ not yet supported for torch.compile")

安装OpenVINO:

从Pypi安装:

带有torch.compile支持的OpenVINO现在可以在OpenVINO预发布包(版本:添加版本)中预览。从这里下载预发布软件包。使用命令从Pypi安装pip install --pre openvino

从源代码构建和安装:

OpenVINO也可以使用此处提供的说明从源代码构建

已知问题

  • 将采样方法更改为DPM++或Karras方法会重新编译模型,因为它对图形进行了一些修改。建议为任何性能测量排除第一代图像的时间
  • 常规Stable Diffusion 2.1目前在离散GPU上存在已知问题。请改用Stable Diffusion 2.1基础版本。

我们一直在努力

apachecn/AiLearning

【布客】中文翻译组