stable diffusion webui 安装摆设(linux体系)

[复制链接]
查看576 | 回复0 | 2023-8-16 16:29:01 | 显示全部楼层 |阅读模式
文中摆设stable diffusion webui所利用的机器是腾讯云服务器linux体系,centos7

一 环境预备

在这里利用anaconda安装,优势就是可以方便地安装和管理软件包,同一体系上可以同时利用差别版本的 Python 和第三方软件包。如果你必要安装多个体系,而且依靠软件版本差别,那就安装anaconda吧。
1、下载Anaconda

   wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
  如果没有wget则可以通过以下下令安装yum install wget -y
2、安装Anaconda

   增加实行权限: chmod +x Anaconda3-2023.03-1-Linux-x86_64.sh
    开始实行:./Anaconda3-2023.03-1-Linux-x86_64.sh
  跟着提示来做,让回车就回车,让yes就yes,安装乐成后会表现如下提示



3、创建Stable Diffusion假造环境

在利用 Conda 管理 Python 环境时,默认环境下会创建一个名为 base 的假造环境,该环境是全局共享的,即在该环境下安装的 Python 包和库都会对体系上的其他所有假造环境和全局环境可见。
如果不举行设置,重新启动就变成下面这个样子
(base) [root@VM-0-4-centos ~]#
为了清楚,也为了后面再摆设其他的AI应用,我们给Stable Diffusion创建单独的假造环境。
   创建假造环境:conda create -n sd python=3.10.6
  




   查看环境列表:conda evn list 
  

 安装git

   conda install git
  查看git版本号



二: stable-diffusion-webui 安装摆设

1、下载代码stable-diffusion-webui

   git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
  2、启动webu.sh

切换到 stable-diffusion-webui目次
方法一: 运行 bash webui.sh如果是root用户,必要注释掉webui.sh中关于root权限的判断。
 方法二:root用户还可以直接运行 bash webui.sh -f

三:常见报错信息

接下来就是办理报错信息了。
1、ERROR: This script must not be launched as root, aborting...




启动时候加个参数: bash webui.sh -f 如许就可以以root启动了。
如果嫌贫苦可以修改 webui.sh脚本代码



2、No matching distribution found for torch==2.0.1

Collecting torch==2.0.1
Could not find a version that satisfies the requirement torch==2.0.1 (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2)
No matching distribution found for torch==2.0.1
You are using pip version 9.0.3, however version 23.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Traceback (most recent call last):
File "launch.py", line 38, in
main()
File "launch.py", line 29, in main
prepare_environment()
File "/home/sdui/stable-diffusion-webui/modules/launch_utils.py", line 254, in prepare_environment
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
File "/home/sdui/stable-diffusion-webui/modules/launch_utils.py", line 101, in run
raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "/home/sdui/stable-diffusion-webui/venv/bin/python3" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 1

标题排查:
1、pip版本不对,导致下载文件报错
conda中默认带的旧版本pip,更换为pip3
卸载:conda uninstall pip
安装:conda install -c anaconda pip
然后运行:bash webui.sh

2、如果无法自动完成下载安装,可以手动举行安装
查看下CUDA版本版本
[code][/code]
   nvidia-smi
    cat /usr/local/cuda/version.txt
  
手动选择版本 https://pytorch.org/get-started/locally/



选择好对应的版本,conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
运行之后,就开始进入各种依靠的下载

3、git版本太低

办理方案:condainstall git

[notice] To update, run: pip install --upgrade pip
Installing gfpgan
Installing clip
Installing open_clip
Cloning Stable Diffusion into /app/stable-diffusion-webui/repositories/stable-diffusion-stability-ai...
Traceback (most recent call last):
File "/app/stable-diffusion-webui/launch.py", line 38, in
main()
File "/app/stable-diffusion-webui/launch.py", line 29, in main
prepare_environment()
File "/app/stable-diffusion-webui/modules/launch_utils.py", line 288, in prepare_environment
git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
File "/app/stable-diffusion-webui/modules/launch_utils.py", line 150, in git_clone
run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
File "/app/stable-diffusion-webui/modules/launch_utils.py", line 101, in run
raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't checkout {name}'s hash: {commithash}.
Command: "git" -C "/app/stable-diffusion-webui/repositories/stable-diffusion-stability-ai" checkout cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf
Error code: 129
stderr: Unknown option: -C
usage: git [--version] [--help] [-c name=value]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
  []

4、报错:libGL.so.1: cannot open shared object file: No such file or directory

   办理方案:yum install mesa-libGL
  Python 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0] Version: v1.3.2 Commit hash: baf6946e06249c5af9851c60171692c44ef633e0 Cloning Taming Transformers into /app/stable-diffusion-webui/repositories/taming-transformers... Cloning K-diffusion into /app/stable-diffusion-webui/repositories/k-diffusion... Cloning CodeFormer into /app/stable-diffusion-webui/repositories/CodeFormer... Cloning BLIP into /app/stable-diffusion-webui/repositories/BLIP... Installing requirements for CodeFormer Installing requirements Launching Web UI with arguments: -f No module 'xformers'. Proceeding without it. Traceback (most recent call last): File "/app/stable-diffusion-webui/launch.py", line 38, in  main() File "/app/stable-diffusion-webui/launch.py", line 34, in main start() File "/app/stable-diffusion-webui/modules/launch_utils.py", line 330, in start import webui File "/app/stable-diffusion-webui/webui.py", line 49, in  from modules import shared, sd_samplers, upscaler, extensions, localization, ui_tempdir, ui_extra_networks, config_states File "/app/stable-diffusion-webui/modules/sd_samplers.py", line 1, in  from modules import sd_samplers_compvis, sd_samplers_kdiffusion, shared File "/app/stable-diffusion-webui/modules/sd_samplers_compvis.py", line 9, in  from modules import sd_samplers_common, prompt_parser, shared File "/app/stable-diffusion-webui/modules/sd_samplers_common.py", line 5, in  from modules import devices, processing, images, sd_vae_approx, sd_samplers, sd_vae_taesd File "/app/stable-diffusion-webui/modules/processing.py", line 11, in  import cv2 File "/app/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/__init__.py", line 181, in  bootstrap() File "/app/stable-diffusion-webui/venv/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/root/anaconda3/envs/sd/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: libGL.so.1: cannot open shared object file: No such file or directory

四: conda 常用的下令

     1、创建环境:conda create --name 环境名称
          用途:用于创建一个新的Conda环境,可以指定环境的名称。
    2、激活环境:conda activate 环境名称
            用途:用于激活指定名称的Conda环境。
    3、停用环境:conda deactivate
           用途:用于停用当前激活的Conda环境。
    4、删除环境:conda remove --name 环境名称 --all
           用途:用于删除指定名称的Conda环境,--all参数表现删除环境及其所有安装的包。
    5、安装包:conda install 包名称
           用途:用于在当前环境中安装指定的包。
    6、升级包:conda update 包名称
          用途:用于更新已安装包的版本。
    7、卸载包:conda remove 包名称
           用途:用于从当前环境中卸载指定的包。
    8、查看已安装的包:conda list
          用途:用于列出当前环境中已安装的包。
    9、搜刮包:conda search 包名称
          用途:用于在Conda仓库中搜刮指定的包。
    10、创建环境配置文件:conda env export > environment.yaml
          用途:用于将当前环境的配置导出到一个YAML文件中,以便在其他地方举行复制或重修环境。
    11、查看配置信息:conda config --show
          表现当前的Conda配置信息,包括通用配置、环境配置和用户配置。
    12、查看某个配置项的值:conda config --show 配置项
          表现特定配置项的当前值,例如:conda config --show channels用于表现当前配置的通道列表。
    13、设置配置项的值:conda config --set 配置项=值
          例如:conda config --set channels conda-forge用于将通道设置为conda-forge。
    14、添加通道:conda config --add channels 通道名称
          向配置中添加一个新的通道,使Conda在包搜刮和安装时优先思量该通道。
    15、移除通道:conda config --remove channels 通道名称
          从配置中移除指定的通道,使Conda不再利用该通道。
    16、列出所有通道:conda config --get channels
           列出当前配置中所有配置的通道。
    17、重置配置项:conda config --remove-key 配置项
          重置指定配置项的值为默认值。
    18、编辑配置文件:conda config --edit
          打开配置文件以举行手动编辑,可以修改各种配置选项。
    19、创建具有指定版本的环境:
      conda create --name myenv python=3.10.6
    20、从环境中导出和导入环境配置
    导出环境配置
    conda env export --name myenv --file environment.yaml
    导入环境配置
    conda env create --file environment.yaml
    21、创建一个假造环境的克隆:
    conda create --name myclone --clone myenv
  


来源:https://blog.csdn.net/forgetmiss/article/details/131237220
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则