Ubuntu 安装 stable-diffusion-webui-docker 常见问题处理方法

安装 Stable Diffusion WebUI Docker

工程地址

https://github.com/AbdBarho/stable-diffusion-webui-docker

第一步是 git clone 下来

Setup

阅读 README 中的 setup,进入页面 https://github.com/AbdBarho/stable-diffusion-webui-docker/wiki/Setup

复制代码
docker compose --profile download up --build
# wait until its done, then:
docker compose --profile [ui] up --build
# where [ui] is one of: auto | auto-cpu | comfy | comfy-cpu

所以,先确保安装了 docker compose,注意,不是 docker-compose

docker compose 安装方法

  1. 进入 docker compose release

  2. 找到对应的版本v2.33.1

  3. 运行安装命令

    curl -L https://github.com/docker/compose/releases/download/v2.33.1/docker-compose-`uname -s-uname -m` -o /usr/local/lib/docker/cli-plugins/docker-compose

    chmod +x /usr/local/lib/docker/cli-plugins/docker-compose

  4. docker compose --version 验证

docker compose --profile download up --build

异常日志如下:

复制代码
02/26 02:37:49 [NOTICE] Download complete: /data/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt
download-1  |
download-1  | Download Results:
download-1  | gid   |stat|avg speed  |path/URI
download-1  | ======+====+===========+=======================================================
download-1  | 142eb3|OK  |   283KiB/s|/data/models/RealESRGAN/RealESRGAN_x4plus.pth
download-1  | 3c541d|OK  |   1.0MiB/s|/data/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt
download-1  | 866f5f|OK  |   233KiB/s|/data/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.pth
download-1  | 6a2f36|ERR |   739KiB/s|/data/models/GFPGAN/GFPGANv1.4.pth
download-1  | 70690b|ERR |       0B/s|/data/models/LDSR/project.yaml
download-1  | 4d1403|ERR |       0B/s|/data/models/LDSR/model.ckpt
download-1  | 466742|OK  |   3.3MiB/s|/data/models/Stable-diffusion/sd-v1-5-inpainting.ckpt
download-1  | 849731|OK  |   2.7MiB/s|/data/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt
download-1  |
download-1  | Status Legend:
download-1  | (OK):download completed.(ERR):error occurred.
download-1  |
download-1  | aria2 will resume download if the transfer is restarted.
download-1  | If there are any errors, then see the log file. See '-l' option in help/man page for details.
download-1 exited with code 2

重复运行该命令,直至成功,成功日志如下:

复制代码
02/26 02:50:02 [NOTICE] Download complete: /data/models/LDSR/model.ckpt
download-1  |
download-1  | Download Results:
download-1  | gid   |stat|avg speed  |path/URI
download-1  | ======+====+===========+=======================================================
download-1  | d12a9e|OK  |       0B/s|/data/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt
download-1  | 5e7060|OK  |       0B/s|/data/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt
download-1  | 00f3d6|OK  |       0B/s|/data/models/Stable-diffusion/sd-v1-5-inpainting.ckpt
download-1  | 274faa|OK  |       0B/s|/data/models/RealESRGAN/RealESRGAN_x4plus.pth
download-1  | 5a2243|OK  |       0B/s|/data/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.pth
download-1  | b8ba07|OK  |   1.8MiB/s|/data/models/LDSR/project.yaml
download-1  | bcb67a|OK  |   880KiB/s|/data/models/GFPGAN/GFPGANv1.4.pth
download-1  | d31924|OK  |   4.3MiB/s|/data/models/LDSR/model.ckpt
download-1  |
download-1  | Status Legend:
download-1  | (OK):download completed.
download-1  | Checking SHAs...
download-1  | /data/models/LDSR/project.yaml: OK
download-1  | /data/models/RealESRGAN/RealESRGAN_x4plus_anime_6B.pth: OK
download-1  | /data/models/RealESRGAN/RealESRGAN_x4plus.pth: OK
download-1  | /data/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt: OK
download-1  | /data/models/GFPGAN/GFPGANv1.4.pth: OK
download-1  | /data/models/LDSR/model.ckpt: OK
download-1  | /data/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt: OK
download-1  | /data/models/Stable-diffusion/sd-v1-5-inpainting.ckpt: OK
download-1  | By using this software, you agree to the following licenses:
download-1  | https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/LICENSE
download-1  | https://github.com/CompVis/stable-diffusion/blob/main/LICENSE
download-1  | https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/LICENSE.txt
download-1  | https://github.com/invoke-ai/InvokeAI/blob/main/LICENSE
download-1  | And licenses of all UIs, third party libraries, and extensions.
download-1 exited with code 0

docker compose --profile [ui] up --build

运行命令如下

复制代码
docker compose --profile auto up --build

报错如下

./clone.sh stable-diffusion-stability-ai

复制代码
=> ERROR [auto download 4/9] RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf   && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif  75.8s
------
 > [auto download 4/9] RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf   && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif:
2.567 + mkdir -p /repositories/stable-diffusion-stability-ai
2.568 + cd /repositories/stable-diffusion-stability-ai
2.568 + git init
2.570 hint: Using 'master' as the name for the initial branch. This default branch name
2.570 hint: is subject to change. To configure the initial branch name to use in all
2.570 hint: of your new repositories, which will suppress this warning, call:
2.570 hint:
2.570 hint:     git config --global init.defaultBranch <name>
2.570 hint:
2.570 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2.570 hint: 'development'. The just-created branch can be renamed via this command:
2.570 hint:
2.570 hint:     git branch -m <name>
2.571 Initialized empty Git repository in /repositories/stable-diffusion-stability-ai/.git/
2.571 + git remote add origin https://github.com/Stability-AI/stablediffusion.git
2.573 + git fetch origin cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf '--depth=1'
75.70 error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
75.70 error: 3601 bytes of body are still expected
75.71 fetch-pack: unexpected disconnect while reading sideband packet
75.71 fatal: early EOF
75.71 fatal: fetch-pack: invalid index-pack output
------
failed to solve: executor failed running [/bin/sh -c . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf   && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif]: exit code: 128

详见 https://github.com/AbdBarho/stable-diffusion-webui-docker/issues/657 ,需要修改两点:

  1. 编辑 /stable-diffusion-webui-docker/services/AUTOMATIC1111/Dockerfile,将 FROM alpine/git:2.36.2 修改为 FROM alpine/git:2.43.0
  2. 编辑 /stable-diffusion-webui-docker/services/AUTOMATIC1111/clone.sh,在行末加上 sleep 200s,如果还是不行,适当扩大 200s,取决于现场网络条件。

ImportError: cannot import name 'TypeIs' from 'typing_extensions'

复制代码
auto-1  |     from .plugin_registry import PluginRegistry
auto-1  |   File "/opt/conda/lib/python3.10/site-packages/altair/utils/plugin_registry.py", line 13, in <module>
auto-1  |     from typing_extensions import TypeIs
auto-1  | ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/opt/conda/lib/python3.10/site-packages/typing_extensions.py)
auto-1 exited with code 1

解决方案详见 https://github.com/AbdBarho/stable-diffusion-webui-docker/issues/729

修改 /stable-diffusion-webui-docker/services/AUTOMATIC1111/Dockerfile, 如下

复制代码
WORKDIR /
RUN --mount=type=cache,target=/root/.cache/pip \
  git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \
  cd stable-diffusion-webui && \
  git reset --hard v1.9.4 && \
  pip install -r requirements_versions.txt && \
  pip install --upgrade typing-extensions

The NVIDIA driver on your system is too old (found version 11040)

复制代码
auto-1  | Installing extension dependencies (if any)
auto-1  | /opt/conda/lib/python3.10/site-packages/timm/models/layers/__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
auto-1  |   warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
auto-1  | no module 'xformers'. Processing without...
auto-1  | no module 'xformers'. Processing without...
auto-1  | No module 'xformers'. Proceeding without it.
auto-1  | The NVIDIA driver on your system is too old (found version 11040). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.: str
auto-1  | Traceback (most recent call last):
auto-1  |   File "/stable-diffusion-webui/modules/errors.py", line 98, in run
auto-1  |     code()
auto-1  |   File "/stable-diffusion-webui/modules/devices.py", line 106, in enable_tf32
auto-1  |     if cuda_no_autocast():
auto-1  |   File "/stable-diffusion-webui/modules/devices.py", line 28, in cuda_no_autocast
auto-1  |     device_id = get_cuda_device_id()
auto-1  |   File "/stable-diffusion-webui/modules/devices.py", line 40, in get_cuda_device_id
auto-1  |     ) or torch.cuda.current_device()
auto-1  |   File "/opt/conda/lib/python3.10/site-packages/torch/cuda/__init__.py", line 778, in current_device
auto-1  |     _lazy_init()
auto-1  |   File "/opt/conda/lib/python3.10/site-packages/torch/cuda/__init__.py", line 293, in _lazy_init
auto-1  |     torch._C._cuda_init()
auto-1  | RuntimeError: The NVIDIA driver on your system is too old (found version 11040). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.
auto-1  |
auto-1  | During handling of the above exception, another exception occurred:
auto-1  |
auto-1  | Traceback (most recent call last):
auto-1  |   File "/stable-diffusion-webui/webui.py", line 13, in <module>
auto-1  |     initialize.imports()
auto-1  |   File "/stable-diffusion-webui/modules/initialize.py", line 36, in imports
auto-1  |     shared_init.initialize()
auto-1  |   File "/stable-diffusion-webui/modules/shared_init.py", line 17, in initialize
auto-1  |     from modules import options, shared_options
auto-1  |   File "/stable-diffusion-webui/modules/shared_options.py", line 4, in <module>
auto-1  |     from modules import localization, ui_components, shared_items, shared, interrogate, shared_gradio_themes, util, sd_emphasis
auto-1  |   File "/stable-diffusion-webui/modules/interrogate.py", line 13, in <module>
auto-1  |     from modules import devices, paths, shared, lowvram, modelloader, errors, torch_utils
auto-1  |   File "/stable-diffusion-webui/modules/devices.py", line 113, in <module>
auto-1  |     errors.run(enable_tf32, "Enabling TF32")
auto-1  |   File "/stable-diffusion-webui/modules/errors.py", line 100, in run
auto-1  |     display(task, e)
auto-1  |   File "/stable-diffusion-webui/modules/errors.py", line 68, in display
auto-1  |     te = traceback.TracebackException.from_exception(e)
auto-1  |   File "/opt/conda/lib/python3.10/traceback.py", line 572, in from_exception
auto-1  |     return cls(type(exc), exc, exc.__traceback__, *args, **kwargs)
auto-1  | AttributeError: 'str' object has no attribute '__traceback__'
auto-1 exited with code 1

遇到这类报错的原因是,pytorch 与 服务器上的显卡驱动版本不一致,要么升级服务器显卡驱动,要么修改 /stable-diffusion-webui-docker/services/AUTOMATIC1111/Dockerfile 中的 pytorch 镜像

复制代码
FROM pytorch/pytorch:2.3.0-cuda11.8-cudnn8-runtime

实际上,这一步应该放在第一步执行

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:

复制代码
auto-1  | Installing extension dependencies (if any)
auto-1  | /opt/conda/lib/python3.10/site-packages/timm/models/layers/__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
auto-1  |   warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
auto-1  | WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
auto-1  |     PyTorch 2.3.0+cu121 with CUDA 1201 (you have 2.3.0)
auto-1  |     Python  3.10.14 (you have 3.10.14)
auto-1  |   Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
auto-1  |   Memory-efficient attention, SwiGLU, sparse and more won't be available.
auto-1  |   Set XFORMERS_MORE_DETAILS=1 for more details

出现这个异常报警一般是显卡和 xfomers 版本不一致导致,详见 https://github.com/facebookresearch/xformers#installing-xformers,找到正确的版本(比如 pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu118),修改

复制代码
RUN --mount=type=cache,target=/root/.cache/pip \
  pip install pyngrok xformers==0.0.26.post1 \
  git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
  git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
  git+https://github.com/mlfoundations/open_clip.git@v2.20.0

复制代码
RUN --mount=type=cache,target=/root/.cache/pip \
  pip install pyngrok \
  git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
  git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
  git+https://github.com/mlfoundations/open_clip.git@v2.20.0

RUN --mount=type=cache,target=/root/.cache/pip pip install xformers==0.0.26.post1 --index-url https://download.pytorch.org/whl/cu118

再次运行 docker compose --profile auto up --build 后,启动正常

相关推荐
CheungChunChiu5 小时前
Linux 内核设备模型与驱动框架解析 ——以 rk-pcie 为例
linux·运维·ubuntu
jingshaoqi_ccc11 小时前
ubuntu 24下面安装docker
ubuntu·docker·eureka
TracyCoder12311 小时前
在Ubuntu上搭建大模型最基础的应用环境
linux·运维·ubuntu
关关长语12 小时前
Vue本地部署包快速构建为Docker镜像
前端·vue.js·docker
水滴与鱼13 小时前
DOCKER制作ROS运行的镜像文件
运维·docker·容器
diegoXie14 小时前
WSL2 跨系统文件移动
linux·ubuntu
杨浦老苏16 小时前
安全的消息传递和协作工具Virola Messenger
docker·即时通讯·群晖·im
阿梦Anmory16 小时前
Windows使用wsl教程
ubuntu·wsl
Keine Zeit16 小时前
虚拟机Linux(Ubuntu)忘记登录密码
linux·运维·ubuntu
石像鬼₧魂石16 小时前
Ubuntu 渗透测试步骤
linux·运维·ubuntu