当前位置:   article > 正文

Centos7 部署 Stable Diffusion_centos7 安装stable diffusion

centos7 安装stable diffusion

参考:https://www.jianshu.com/p/ff81bb76158a

一、安装最新版 git

yum install libcurl-devel curl-devel -y
  1. # 安装依赖库
  2. yum -y install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel curl-devel libcurl-devel
  3. # 下载安装包
  4. wget https://www.kernel.org/pub/software/scm/git/git-2.42.0.tar.xz --no-check-certificate
  5. # 解压安装包,进入目录
  6. tar -vxf git-2.42.0.tar.xz
  7. cd git-2.40.0
  8. # 编译、安装
  9. ./configure
  10. make -j4 && make -j4 install
  11. # 查看是否安装成功
  12. git --version

clone 代码到本地:

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.

解决办法:

  1. 手动下载 https://huggingface.co/openai/clip-vit-large-patch14/tree/main
  2. 下载文件为:
  3. 1、config.json
  4. 2、flax_model.msgpack
  5. 3、merges.txt
  6. 4、preprocessor_config.json
  7. 5、pytorch_model.bin
  8. 6、special_tokens_map.json
  9. 7、tokenizer.json
  10. 8、tokenizer_config.json
  11. 9、vocab.json
  12. 在项目目录下创建(stable-diffusion-webui)
  13. mkdir -p openai/clip-vit-large-patch14
  14. 把以上九个文件放到新文件夹下

5、运行报错

  1. # 报错1
  2. ImportError: libX11.so.6: cannot open shared object file: No such file or directory
  3. # 报错2
  4. 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’

解决方法:

  1. yum install xz-devel python-backports-lzma backports.lzma -y
  2. pip install backports.lzma
  3. pip install xformers

修改文件第 27 行左右的地方

vim /usr/local/lib/python3.10/lzma.py
  1. try:
  2. from _lzma import *
  3. from _lzma import _encode_filter_properties, _decode_filter_properties
  4. except ImportError:
  5. from backports.lzma import *
  6. from backports.lzma import _encode_filter_properties, _decode_filter_properties

8、运行报错

  1. File "/data/stable-diffusion/stable-diffusion-webui/modules/processing.py", line 2, in <module>
  2. import cv2
  3. File "/data/stable-diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
  4. bootstrap()
  5. File "/data/stable-diffusion/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
  6. native_module = importlib.import_module("cv2")
  7. File "/usr/local/python3/lib/python3.10/importlib/__init__.py", line 126, in import_module
  8. return _bootstrap._gcd_import(name[level:], package, level)
  9. ImportError: dlopen: cannot load any more object with static TLS

解决办法:

vim /data/stable-diffusion/stable-diffusion-webui/modules/initialize.py
  1. import importlib
  2. import logging
  3. import os
  4. import cv2
  5. import sys
  6. ...
  7. def imports():
  8. logging.getLogger("torch.distributed.nn").setLevel(logging.ERROR) # sshh...
  9. logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
  10. import cv2 # 在 import torch 之前 import cv2
  11. import torch # noqa: F401
  12. startup_timer.record("import torch")

三、启动参数设置

编辑文件 webui-user.sh

  1. # 设置启动参数
  2. export COMMANDLINE_ARGS="--precision autocast --listen --api --no-half --xformers --enable-insecure-extension-access"
  3. # 设置模型共享或单独指定模型所在目录
  4. export A1111_HOME="/data/stable-diffusion/stable-diffusion-webui"
  5. export COMMANDLINE_ARGS="${COMMANDLINE_ARGS} \
  6. --ckpt-dir ${A1111_HOME}/models/Stable-diffusion \
  7. --hypernetwork-dir ${A1111_HOME}/models/hypernetworks \
  8. --embeddings-dir ${A1111_HOME}/embeddings \
  9. --lora-dir ${A1111_HOME}/models/Lora \
  10. --vae-dir ${A1111_HOME}/models/VAE}"
  11. # 设置虚拟环境所在目录
  12. venv_dir="/data/webui-forge/venv"

四、启动 webui

sh webui.sh

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/905563
推荐阅读
相关标签
  

闽ICP备14008679号