参考:https://www.jianshu.com/p/ff81bb76158a
yum install libcurl-devel curl-devel -y
- # 安装依赖库
- yum -y install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel curl-devel libcurl-devel
-
- # 下载安装包
- wget https://www.kernel.org/pub/software/scm/git/git-2.42.0.tar.xz --no-check-certificate
-
- # 解压安装包,进入目录
- tar -vxf git-2.42.0.tar.xz
- cd git-2.40.0
-
- # 编译、安装
- ./configure
-
- make -j4 && make -j4 install
-
- # 查看是否安装成功
- git --version
stable diffusion webui:https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
stable diffusion webui forge:https://github.com/lllyasviel/stable-diffusion-webui-forge.git
建议使用 sd webui forge ,优化更好
1、git clone 比较慢
解决办法:设置代理 https://blog.csdn.net/dszgf5717/article/details/130735389
2、pip install 比较慢
解决办法:更换源或设置代理 https://blog.csdn.net/dszgf5717/article/details/53138298
3、无法使用GPU
Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
解决办法:一般是 pytorch 装的版本不对,重装
i、先卸载原来的
pip uninstall torch torchvision torchaudio
ii、安装与显卡相匹配的版本
pytorch 官网 https://pytorch.org/get-started/locally/
参考文章:https://blog.csdn.net/weixin_41803482/article/details/109231249
4、运行报错
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://huggingface.co/openai/clip-vit-large-patch14/tree/main
- 下载文件为:
- 1、config.json
- 2、flax_model.msgpack
- 3、merges.txt
- 4、preprocessor_config.json
- 5、pytorch_model.bin
- 6、special_tokens_map.json
- 7、tokenizer.json
- 8、tokenizer_config.json
- 9、vocab.json
-
- 在项目目录下创建(stable-diffusion-webui)
-
- mkdir -p openai/clip-vit-large-patch14
-
- 把以上九个文件放到新文件夹下
5、运行报错
- # 报错1
-
- ImportError: libX11.so.6: cannot open shared object file: No such file or directory
-
- # 报错2
-
- ImportError: libXext.so.6: cannot open shared object file: No such file or directory
解决办法:
yum install libX11 libXext -y
6、运行报错
Cannot locate TCMalloc (improves CPU memory usage)
解决办法:
yum install gperftools gperftools-devel -y
参考文章:https://blog.csdn.net/weixin_57451673/article/details/133919472
7、运行报错
出现 No module named ‘_lzma’
解决方法:
- yum install xz-devel python-backports-lzma backports.lzma -y
- pip install backports.lzma
- pip install xformers
修改文件第 27 行左右的地方
vim /usr/local/lib/python3.10/lzma.py
- try:
- from _lzma import *
- from _lzma import _encode_filter_properties, _decode_filter_properties
- except ImportError:
- from backports.lzma import *
- from backports.lzma import _encode_filter_properties, _decode_filter_properties
8、运行报错
- File "/data/stable-diffusion/stable-diffusion-webui/modules/processing.py", line 2, in
- import cv2
- File "/data/stable-diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/__init__.py", line 181, in
- bootstrap()
- File "/data/stable-diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
- native_module = importlib.import_module("cv2")
- File "/usr/local/python3/lib/python3.10/importlib/__init__.py", line 126, in import_module
- return _bootstrap._gcd_import(name[level:], package, level)
- ImportError: dlopen: cannot load any more object with static TLS
解决办法:
vim /data/stable-diffusion/stable-diffusion-webui/modules/initialize.py
- import importlib
- import logging
- import os
- import cv2
- import sys
-
- ...
-
- def imports():
- logging.getLogger("torch.distributed.nn").setLevel(logging.ERROR) # sshh...
- logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
-
- import cv2 # 在 import torch 之前 import cv2
- import torch # noqa: F401
- startup_timer.record("import torch")
编辑文件 webui-user.sh
- # 设置启动参数
- export COMMANDLINE_ARGS="--precision autocast --listen --api --no-half --xformers --enable-insecure-extension-access"
-
- # 设置模型共享或单独指定模型所在目录
- export A1111_HOME="/data/stable-diffusion/stable-diffusion-webui"
- export COMMANDLINE_ARGS="${COMMANDLINE_ARGS} \
- --ckpt-dir ${A1111_HOME}/models/Stable-diffusion \
- --hypernetwork-dir ${A1111_HOME}/models/hypernetworks \
- --embeddings-dir ${A1111_HOME}/embeddings \
- --lora-dir ${A1111_HOME}/models/Lora \
- --vae-dir ${A1111_HOME}/models/VAE}"
-
- # 设置虚拟环境所在目录
- venv_dir="/data/webui-forge/venv"
sh webui.sh