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

ops/2025/3/4 17:42:40/

安装 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__14">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-composechmod +x /usr/local/lib/docker/cli-plugins/docker-compose
  1. docker compose --version 验证

docker_compose_profile_download_up_build_24">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_83">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.0RUN --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 后,启动正常


http://www.ppmy.cn/ops/163088.html

相关文章

父子继承与转型

ISettings为接口&#xff0c;Settings是实现类。 1、Settings可以自动转型为ISettings&#xff1b; 2、List<Settings>不可以自动转型为List<ISettings>&#xff0c; 原因在于泛型类型在 Java 中是 不可协变&#xff08;invariant&#xff09;的&#xff0c;即使…

Vue核心知识:动态路由实现完整方案

在Vue中实现动态路由&#xff0c;并结合后端接口和数据库表设计&#xff0c;是一个复杂的项目&#xff0c;需要多个技术栈和步骤的配合。以下将详细描述整个实现过程&#xff0c;包括数据库设计、后端接口设计、前端路由配置以及如何实现动态路由的功能。 目录 一、需求分析二…

蓝桥杯牛客1-10重点(自用)

1 import mathdef lcm(a,b):return a * b // math.gcd(a, b) # math.gcd(a, b)最小公倍数 a,b map(int,input().split()) # a int(input()) # 只读取一个整数 # print(a) print(lcm(a,b)) 2 import os import sysdef fly(lists,n):count 0flag Falsefor i in range(1,n…

特征分解(Eigen decomposition)在深度学习中的应用与理解

特征分解在深度学习中的应用与理解 特征分解&#xff08;Eigendecomposition&#xff09;是线性代数中的一个核心工具&#xff0c;在深度学习领域有着广泛的应用&#xff0c;尤其是在涉及矩阵操作和概率模型时。对于研究者来说&#xff0c;理解特征分解不仅有助于掌握数学基础…

火山引擎 DeepSeek R1 API 使用小白教程

一、火山引擎 DeepSeek R1 API 申请 首先需要三个要素&#xff1a; 1&#xff09;API Key 2&#xff09;API 地址 3&#xff09;模型ID 1、首先打开火山引擎的 DeepSeek R1 模型页面 地址&#xff1a;账号登录-火山引擎 2、在页面右下角&#xff0c;找到【推理】按钮&#…

朝天椒USB Server为赛力斯集团解决网银U盾难题

近期&#xff0c;赛力斯集团的财务部门引进了朝天椒USB Server&#xff0c;用几台USB服务器解决了集团困扰多年的银行U盾管理难题。 一、背景 赛力斯集团是一家以新能源汽车为核心业务的科技制造企业&#xff0c;A股上市公司&#xff0c;中国企业500强。赛力斯集团作为一家大型…

二、QT和驱动模块实现智能家居-----问题汇总1

1、文件地址改变后必须在QT下更改地址 2、指定了QT内Kits下的Sysroot头文件地址&#xff0c;但是还是找不到头文件&#xff1a; 3、提示无法执行QT程序&#xff1a;先干掉之前的QT程序 ps //查看程序PIDkill -9 PID 4、无法执行QT程序 1&#xff09;未设置环境变量 …

软件工程:软件需求之需求分析方法

目录 前言 需求分析方法 工具和方法 具体分析方法 对运行环境的影响 ​编辑 前言 本文重点介绍开展软件需求分析的方法。 需求分析方法 工具和方法 软件需求可以维护在ALM系统中&#xff0c;譬如&#xff1a;doors&#xff0c;codeBeamer等&#xff0c;JIRA适合互联网行…