win11下部署stable diffusion docker版遇到的问题和解决方案

这篇具有很好参考价值的文章主要介绍了win11下部署stable diffusion docker版遇到的问题和解决方案。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

背景

为了在本地愉快流畅地体验stable diffsion,且不希望直接在windows中安装过多复杂的环境,顺便体验容器的部署和发布的便利,决定选择stable diffusion的docker版(AbdBarho版)。

网上已经有很多stable diffusion的部署文章,有很多甚至是零基础或者一键安装的,但自己尝试之后才发现还是有很多坑,真正操作起来并没有那么容易。这些坑的来源主要是两个方面:一个是网络下载问题,另一个是docker中的GPU运行问题。

写这篇文章的主要目的并非详细介绍环境构建的步骤,而是记录部署过程中踩过的坑,以及相关的解决方案。如果你已经尝试了docker版部署并遇到了问题,可以做个参考。

系统需求

网上很多教程都是在Linux上部署的,但是有一点要明确:虚拟机上的Linux是不行的
因为如果要在虚拟机上使用GPU,就意味着GPU必须虚拟化或者透传给虚拟机使用,就像CPU和内存的虚拟化一样,但GPU并不支持虚拟化(也许有,但你总不会为了部署个软件去改bios吧),所以即使你在虚拟机中安装了GPU驱动也无法使用GPU。

其次,由于docker只能在linux上运行,就意味着你必须使用wsl,在wsl里再安装docker。
(也可以安装docker-desktop,但似乎坑比较多,不如直接在wsl中直接安装docker-ce)。

需要安装的软件

windows上

Nvidia显卡驱动

https://www.nvidia.com/en-us/geforce/drivers/

wsl2

wsl --install

Ubuntu 22.04

wsl --install -d Ubuntu-22.04

git

(地址略)

Ubuntu上

针对wsl2的cuda驱动

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local

docker

curl https://get.docker.com | sh

stable diffusion

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

另外,nvidia-docker和docker-compose个人理解是不用安装的。
前者是docker的一个插件,用来自动给docker run增加gpu使用的参数,而最新版的docker在yml中已经支持gpu参数了,且在实际部署的过程中并没有用到过nvidia-docker命令。而后者docker也有自带的docker compose命令,并不需要使用docker-compose命令。

下载问题的解决方案

github上官方的安装命令非常简单,两个compose命令就可以自动下载安装包生成镜像并运行:

sudo service docker start
cd /mnt/d/yourpath/stable-diffusion-webui-docker
sudo docker compose --profile download up --build
sudo docker compose --profile auto up

但在国内执行时遇到的最多的问题就是下载中断。这时候如果重试仍然下载不了,就需要手动修改dockerfile文件来解决。

docker compose profile download下载错误

webui-docker-download-1  | edc1d3|OK  |   1.7MiB/s|/data/VAE/vae-ft-mse-840000-ema-pruned.ckpt
webui-docker-download-1  | e85b41|OK  |    99KiB/s|/data/RealESRGAN/RealESRGAN_x4plus_anime_6B.pth
webui-docker-download-1  | 011c41|OK  |   2.4KiB/s|/data/LDSR/project.yaml
webui-docker-download-1  | d56dbc|OK  |   1.6MiB/s|/data/LDSR/model.ckpt
webui-docker-download-1  | 53c224|OK  |   2.0MiB/s|/data/StableDiffusion/v1-5-pruned-emaonly.ckpt
webui-docker-download-1  | a573f8|OK  |   1.9MiB/s|/data/StableDiffusion/sd-v1-5-inpainting.ckpt
webui-docker-download-1  | 9521b5|ERR |    28KiB/s|/data/RealESRGAN/RealESRGAN_x4plus.pth
webui-docker-download-1  | 3a3491|ERR |    87KiB/s|/data/GFPGAN/GFPGANv1.4.pth

一般重新执行一次就可以(会续传)

github依赖的下载失败问题

如果碰到类似下面的github下载超时的问题:

 #0 120.9 fatal: unable to access 'https://github.com/crowsonkb/k-diffusion.git/': HTTP/2 stream 1 was
 not closed cleanly before end of the underlying stream

有一些github依赖无论重试多少次都会失败,可以把dockerfile(stable-diffusion-webui-docker\services\AUTOMATIC1111\Dockerfile)中的github手动改为kgithub即可成功下载。
例如:

RUN . /clone.sh k-diffusion https://kgithub.com/crowsonkb/k-diffusion.git 5b3af030dd83e0297272d861c19477735d0317ec
RUN . /clone.sh clip-interrogator https://kgithub.com/pharmapsychotic/clip-interrogator 2486589f24165c8e3b303f84e9dbbea318df83e8
#0 0.910 04/13 13:43:47 [ERROR] CUID#7 - Download aborted. URI=https://kgithub.com/AbdBarho/stable-diffusion-webui-docker/releases/download/5.0.0/xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl
#0 0.910 Exception: [AbstractCommand.cc:351] errorCode=1 URI=https://kgithub.com/AbdBarho/stable-diffusion-webui-docker/releases/download/5.0.0/xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl
#0 0.910   -> [SocketCore.cc:1018] errorCode=1 SSL/TLS handshake failure:  `not signed by known authorities or invalid' `expired'

手动下载libgoogle-perftools-dev_2.7-1_amd64.deb和xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl(改名为wheel.whl),注释掉aria2c下载命令,改为使用COPY命令拷贝到容器可解决:

#RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/5.0.0/xformers-0.0.17.dev449-cp310-cp310-manylinux2014_x86_64.whl'
COPY wheel.whl /
COPY libgoogle-perftools-dev_2.7-1_amd64.deb /
#0 141.8 pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
#0 63.88   Downloading gradio-3.15.0-py3-none-any.whl (13.8 MB)
#0 141.8      ╸                                        0.2/13.8 MB 3.2 kB/s eta 1:10:40

设置pip全局镜像源可解决:

pip config --global set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config --global set install.trusted-host mirrors.aliyun.com
pip install -r requirements_versions.txt
#0 0.451 fatal: unable to access 'https://kgithub.com/AUTOMATIC1111/stable-diffusion-webui.git/': server certificate verification failed. CAfile: none CRLfile: none

关闭证书验证可解决:

git config --global http.version HTTP/1.1
git config --global http.sslverify false
git clone https://kgithub.com/AUTOMATIC1111/stable-diffusion-webui.git
failed to solve: process "/bin/bash -ceuxo pipefail apt-get -y install libgoogle-perftools-dev && apt-get clean" did not complete successfully: exit code: 100

向 /etc/apt/sources.list 文件中添加镜像可解决:

RUN echo 'deb http://ftp.cn.debian.org/debian buster main' | tee -a /etc/apt/sources.list
RUN apt-get -y install libgoogle-perftools-dev && apt-get clean

容器中无法使用GPU的问题

容器启动失败,提示找不到GPU驱动:

webui-docker-auto-1  | RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx

在容器中执行nvidia-smi提示下面信息:

Failed to initialize NVML: GPU access blocked by the operating system
Failed to properly shut down NVML: GPU access blocked by the operating system

搜索发现这个是微软wsl2自身的问题:
https://github.com/microsoft/WSL/issues/9962

解决方案就是下载最新的wsl1.2.3版本并安装:
https://github.com/microsoft/WSL/releases/tag/1.2.3

wsl --shutdown
$Package = Get-AppxPackage MicrosoftCorporationII.WindowsSubsystemforLinux -AllUsers
Remove-AppxPackage $Package -AllUsers
Add-AppxPackage Microsoft.WSL_1.2.3.0_x64_ARM64.msixbundle

其它问题

docker启动时有如下错误:

mount: /sys/fs/cgroup/cpuset: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/cpu: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/cpuacct: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/blkio: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/memory: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/devices: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/freezer: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/net_cls: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/perf_event: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/net_prio: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/hugetlb: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/pids: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/rdma: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.
mount: /sys/fs/cgroup/misc: wrong fs type, bad option, bad superblock on cgroup, missing codepage or helper program, or other error.

该错误是wsl 1.1.6.0的bug(但似乎并不影响docker启动)。升级到1.2.3可解决。文章来源地址https://www.toymoban.com/news/detail-465630.html

到了这里,关于win11下部署stable diffusion docker版遇到的问题和解决方案的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • stable diffusion 1.5版本windows本地部署遇到的问题

    本人在本地部署时,主要参考了知乎上的这篇文章: Stable Diffusion安装教程(有问题可留言),将自己部署中遇到的问题记录下来,以供参考。 我这里没有使用windows的cmd,用的是Anaconda,因为1.5版本需要Python 3.10.6,而我又不想卸载之前的版本,创建一个conda虚拟环境即可解决

    2024年02月12日
    浏览(49)
  • win11从Github上源码安装AUTOMATIC1111/stable-diffusion-webui(使用anaconda+外接固态硬盘的解决方案)

    主要参考文章: 从零开始,手把手教你本地部署Stable Diffusion Webui AI绘画(Win系最新版) - 知乎 (zhihu.com) (其实在安装过程中因为遇到很多坑,已经看了非常多的安装教程,但写这篇备忘的时候已经都找不到了。感谢这些作者无私分享,很遗憾这里只能上这个最后一篇参考的文

    2024年02月05日
    浏览(35)
  • Stable Diffusion WebUI本地部署中遇到的一些错误

    进来AI绘画大火,我便尝试在本地部署一下,电脑是M1的MacBook,不过windows应该也差不多。 参考官网的方法一步步安装,虽然最后成功了,但中途还是有不少问题。 首先安装homebrew,由于我早就已经安装好了,自然也没遇到什么问题。初次安装的朋友若按照homebrew官网的方法安

    2024年02月03日
    浏览(38)
  • Stable Diffusion/Win/本地部署

    一、本地部署 Stable Diffusion 前言 目前市面上比较权威,并能用于工作中的AI绘画软件其实就两款。一个叫Midjourney(简称MJ),另一个叫Stable-Diffusion(简称SD)。MJ需要付费使用,而SD开源免费,但是上手难度和学习成本略大,并且非常吃电脑配置(显卡、内存)。 E和Midjourne

    2024年01月16日
    浏览(33)
  • win11安装stable diffusion webui(AUTOMATIC1111/stable-diffusion-webui) +anaconda+外接固态硬盘

    主要参考文章: 从零开始,手把手教你本地部署Stable Diffusion Webui AI绘画(Win系最新版) - 知乎 (zhihu.com) (其实在安装过程中因为遇到很多坑,已经看了非常多的安装教程,但写这篇备忘的时候已经都找不到了。感谢这些作者无私分享,很遗憾这里只能上这个最后一篇参考的文

    2024年02月09日
    浏览(34)
  • 【stable diffusion】Win10部署本地教程

    配置stable diffusion需要安装pycharm、anaconda,还有cuda用于gpu加速。这里由于我之前跑神经网络已经都装了,就省略了。 AUTOMATIC1111 创建了Stable Diffusion web UI,因此基本是按照这里进行部署的 https://github.com/AUTOMATIC1111/stable-diffusion-webui git是用来在github下载项目的,跟在github网页上直

    2024年02月03日
    浏览(39)
  • 记录内网Docker启动Stable-Diffusion遇到的几个坑

    摘要: 最近看到K8s启动stable-diffusion的文章,想着在自己开发环境复现一下。没想到在内网环境还遇到这么多问题,记录一下。 本文分享自华为云社区《内网Docker启动Stable-Diffusion(AI作画)》,作者:tsjsdbd 。 最近看到K8s启动stable-diffusion的文章,想着在自己开发环境复现一下

    2024年02月05日
    浏览(32)
  • Stable-Diffusion|window10安装GPU版本的 Stable-Diffusion-WebUI遇到的一些问题(一)

    教程主要参考: AI绘画第一步,安装Stable-Diffusion-WebUI全过程 ! Stable Diffusion WebUI使用手冊(正體中文)|Ivon的部落格 具体记录一下笔者除了按照上述教程,遇到坑的地方 python一定要3.10 如果不是,就新建一个conda环境 安装python库的时候可以用其他源: 笔者之前设置过,跳过 此

    2024年02月17日
    浏览(39)
  • stable-diffusion-webui(AI绘画)项目实现,即遇到的问题

    为了使环境中的库版本不会乱,导致自己电脑原来一些项目无法运行最好使用虚拟环境 下载miniconda  在搜索中搜所miniconda找到 建立虚拟环境 每次运行激活这个虚拟环境 下载git 安装cuda,下面有详细安装流程 进入大点的盘下部署项目 下载初始模型如果不下载好像在使用时会

    2024年02月04日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包