安装stable diffusion过程记录

主要参考安装过程:https://nenly.notion.site/c5805e7ae26b4683a277c5586ea05904

使用阿里云GPU服务器:https://pai.console.aliyun.com/?regionId=cn-shanghai&spm=5176.12818093_47.0.0.3be916d0zZsZWl&workspaceId=433574#/notebook/dsw-42288b06273f627b/config

模型下载网站:https://civitai.com/

安装顺序:1、2、7、4、5

主要遇到的难题:

1、一些博主推荐的SD基础模型用的百度盘分享,下载贼拉慢,简直受不了,所以手动去C站下载一个基础模型。

2、下载好后,上传到阿里云DSW服务器上,上传贼拉慢,被限流。所以得使用阿里云盘,挂载上去,虽然也慢,但是比直接上传服务器快些了。

3、准备执行脚本安装报错:This script must not be launched as root, aborting…

解决方法:./webui.sh -f #强制执行

4、安装SD时下载依赖贼拉慢

pip主要切换清华镜像源和阿里云镜像源,来回切换然后安装webui,需要不停尝试。按照经验,刚开始使用清华源,安装tb-nightly失败时,再切换阿里云源,继续断点续装,基本ok。

解决方法:https://www.bilibili.com/read/cv29812530/?jump_opus=1

亲测有效。

5、No matching distribution found for tb-nightly

解决方法:https://www.fujieace.com/python/error-no-matching-distribution-found-for-tb-nightly.html

https://blog.csdn.net/weixin_46455141/article/details/131353266

6、经常下载依赖中断,不断断点续装

7、creating model quickly: OSError。OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer

解决方法:https://zhuanlan.zhihu.com/p/681188665

9、NotImplementedError: No operator found for memory_efficient_attention_forward with inputs:

原因: xformers版本问题,0.0.18版本适用于pytorch2.0,webui现在默认的版本是1.13.1,所以不兼容。可以用python -m xformers.info来查看xformers的适配情况。解决: 降低xformers版本,pip install xformers==0.0.16

原文链接:https://blog.csdn.net/Huang_Fj/article/details/130105611

最后安装的xformers==0.0.22版本

10、安装tagger

https://zhuanlan.zhihu.com/p/684871772

11、安装controlnet

https://blog.csdn.net/qq_43377653/article/details/130646734

安装插件:https://blog.csdn.net/a1112315165/article/details/134637465

操作方法和案例:https://waytoagi.feishu.cn/wiki/ZrpPwKPwji25KmkKVxmcT686nfh

提示词深入:https://baijiahao.baidu.com/s?id=1775334211764240084&wfr=spider&for=pc

8、安装yum:E: Unable to locate package yum 问题解决

真正解决方案:https://blog.51cto.com/u_16013293/6151280

//备份本地源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
#国内镜像
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

替换完成后

sudo apt-get clean all
sudo apt-get update

更新的时候报错:Err:1 http://mirrors.aliyun.com/ubuntu bionic InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32

更换源之后需要添加公钥,执行以下命令:

注意:这里的recv-keys就是报错中的key,粘贴过来即可

公钥:3B4FE6ACC0B21F32(报错的公钥)

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 公钥

此时再次执行:

sudo apt-get update
sudo apt-get install yum

开始安装yum,到了这一步就安装成功了,验证下是否可用

9、yum报错:There are no enabled repos问题原因及解决

可能是相关yum源被删除了:

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all && yum makecache

http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xm [Errno 14] HTTP Error 404 - Not Found

解决方法:http://www.manongjc.com/detail/41-upvdzrhmxrxvlyv.html

10、An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on

https://zhuanlan.zhihu.com/p/684871772

总结

放弃手动安装了,各种插件的安装太痛苦了。

换了个思路,使用秋叶整合包是一样的,所有依赖都打好包了,那么直接传到linux环境不就行了吗?就这样干。

遇到的问题:

1、conda创建环境报错

配置镜像源:https://blog.csdn.net/qq_45904458/article/details/132183382

2、conda: error: argument COMMAND: invalid choice: 'activate'

https://blog.csdn.net/zhanlong11/article/details/135309140

每次使用webui都要切换空间:conda activate webui

然后安裝torch:

conda install pytorch==2.1.1 torchvision==0.16.1 torchaudio==2.1.1 pytorch-cuda=11.8 -c pytorch -c nvidia

3、下载秋叶整合包,删除git、python目录,然后分包压缩,不然包实在太大。models单独提出来压缩,总目录再压缩。

4、p7zip安装:

输入命令`sudo apt-get update`以更新系统软件包列表。

输入命令`sudo apt-get install p7zip-full`来安装7z命令。

5、上传到环境后,组装压缩包

6、到stable diffusion webui目录执行命令:python launch.py

会开始启动,过程中会自动下载依赖

ControlNet init warning: Unable to install insightface automatically. Please try run `pip install insightface` manually

注意启动时的打印报错,往往要解决,手动下载依赖等

例如下面的:

pip install datasets==2.13.0

pip install huggingface insightface huggingface_hub==0.21.4

pip install face_recognition

7、No matching distribution found for tb-nightly

解决方法:https://www.fujieace.com/python/error-no-matching-distribution-found-for-tb-nightly.html

https://blog.csdn.net/weixin_46455141/article/details/131353266

8、creating model quickly: OSError。OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer

解决方法:https://zhuanlan.zhihu.com/p/681188665

9、Could not locate model-keyword extension

重新安装model-keyword扩展,安装好就不会出现这个提示

10、安裝tagger会遇到的问题

huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

注意,修改完成后,重新执行python launch.py

https://zhuanlan.zhihu.com/p/684871772

11、使用easyphoto训练

easyphoto训练:https://cloud.tencent.com/developer/article/2358570

https://zhuanlan.zhihu.com/p/681308962

遇到的问题,主要是勾选validation会碰见unet验证报错:INFO - __main__ - Running validation error, skip it.Error info: UNet2DConditionModel.forward() got an unexpected keyword argument 'added_cond_kwargs'.

解决方法:加一行代码

进阶:

小红书instanceID部署:https://www.bilibili.com/read/cv31000540

官方源址:https://github.com/InstantID/InstantID

官方模型下载:https://mp.weixin.qq.com/s/qpMvZajNI2WovyymALAajQ

下载lcm-lora-sdxl模型:https://huggingface.co/latent-consistency/lcm-lora-sdxl/tree/main

if not USE_PEFT_BACKEND:

raise ValueError("PEFT backend is required for this method.")

解决方法:https://blog.csdn.net/weixin_43457608/article/details/136060188

运行instanceID爆显存: If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation

把图片size改小,不然爆显存。

安装ComfyUI:https://blog.csdn.net/weixin_42735060/article/details/136096152

mv extra_model_paths.yaml.example extra_model_paths.yaml

工作流下载:https://comfyworkflows.com/workflows/ce41e3cc-7a01-4f01-ae5e-8c69145e4521

ComfyUI使用instanceID:https://zhuanlan.zhihu.com/p/682107843

技术杂文选 文章被收录于专栏

记录自己工作的技术积累

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务