当前位置:首页 » 《随便一记》 » 正文

Stable Diffusion WebUI 安装记录[Ubuntu服务器]

16 人参与  2024年04月11日 17:35  分类 : 《随便一记》  评论

点击全文阅读


前言

在远程服务器(Ubuntu)上安装Stable Diffusion WebUI。服务器是4090,所以在服务器上配置。原本是MobaXterm SSH连接服务器,建议用vscode连接。

尝试了给服务器出海但不知道为什么还是不行。GitHub上我收到一个回答说遇到这些问题的都是中国人……想起来也确实。但是下载模型什么的还是要出海,可以下好了再传到服务器上。

找了一圈在Ubuntu服务器上通过远程连接安装Stable Diffusion WebUI的不多,因此自己记录一下。

过程

进入官方GitHub仓库

按官方说的下载它的webui.sh

wget -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh

新建并进入conda虚拟环境,安装时注意[python版本>3.10]!!

但是后面运行它会自己安装一个venv的虚拟环境,跟conda的不一样。运行的python也不是conda的python。所以我准备修改这个python为我conda虚拟环境的python。

修改python路径

打开webui.sh修改47行处的python路径为自己conda虚拟环境的python路径。可用

whereis python

查看python路径。

下图是修改后的结果。虽然这个文件头上说不要对这里做任何修改,问题是没有这个webui-user.sh文件。

运行webui.sh

bash webui.sh

可能glone主仓库的时候会有问题,这个时候建议在官网直接下载它的zip解压(注意放到webui.sh同一文件夹下,并把文件夹名修改为stable-diffusion-webui)。

报错合集

下面的错误如果解决了就再次运行webui.sh,应该就会遇到下一个错误。

仓库无法访问就手动glone部分仓库

下载过程会遇到好些个仓库glone问题,这里需要手动glone并放到相应文件夹下。至于是哪些,等它报错。

比如这个

fatal: 无法访问 'https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git/':GnuTLS recv error (-110): The TLS connection was non-properly terminated.Traceback (most recent call last):  File "/home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/launch.py", line 48, in <module>    main()  File "/home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/launch.py", line 39, in main    prepare_environment()  File "/home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/modules/launch_utils.py", line 410, in prepare_environment    git_clone(assets_repo, repo_dir('stable-diffusion-webui-assets'), "assets", assets_commit_hash)  File "/home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/modules/launch_utils.py", line 191, in git_clone    run(f'"{git}" clone --config core.filemode=false "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)  File "/home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/modules/launch_utils.py", line 115, in run    raise RuntimeError("\n".join(error_bits))RuntimeError: Couldn't clone assets.Command: "git" clone --config core.filemode=false "https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git" "/home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/repositories/stable-diffusion-webui-assets"Error code: 128

就把这个无法访问的仓库glone到最后一行说的那个路径,如果GitHub glone失败可以去gitte上找同名的链接,比如上面那个的gitte仓库就这样解决:

git clone https://gitee.com/yt-tech/stable-diffusion-webui-assets.git /path/to/yours

glone gitte仓库可能会与GitHub仓库的最新分支不一样,因此可能会有以下提示,这个我暂时也不清楚怎么办,不过好在这个暂不影响。

注意:正在切换到 '45c443b316737a4ab6e40413d7794a7f5657c19f'。您正处于分离头指针状态。您可以查看、做试验性的修改及提交,并且您可以在切换回一个分支时,丢弃在此状态下所做的提交而不对分支造成影响。如果您想要通过创建分支来保留在此状态下所做的提交,您可以通过在 switch 命令中添加参数 -c 来实现(现在或稍后)。例如:  git switch -c <新分支名>或者撤销此操作:  git switch -通过将配置变量 advice.detachedHead 设置为 false 来关闭此建议HEAD 目前位于 45c443b Fix license-files setting for project (#71)

一些模型的下载

这个也建议在官网下载并放到相应文件夹下。

Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to /home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors

下载clip-vit-large-patch14

去huggingface下载这个clip-vit-large-patch14文件夹,并放到stable-diffuison-webui/下。

没有xformers

最后可能还有一个没有xformers加速的提示,

Launching Web UI with arguments: no module 'xformers'. Processing without...no module 'xformers'. Processing without...No module 'xformers'. Proceeding without it.

就安装它

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xformers

这个我也是不清楚为什么python已经改成自己的路径了还是显示没有装上xformers。但是这个影响不大,安装后提示少了两个……有大佬可以指点一下吗

Launching Web UI with arguments: No module 'xformers'. Proceeding without it.Loading weights [3f6c1effb3] from 

大功告成

最后终端显示有个local URL就是成功了!!!

Running on local URL:  http://127.0.0.1:7860To create a public link, set `share=True` in `launch()`.Creating model from config: /home/hyj/python_files/Generate/Diffusion/StableDiffusion/sd_from_webui/stable-diffusion-webui/configs/v1-inference.yamlStartup time: 9.0s (prepare environment: 1.6s, import torch: 3.0s, import gradio: 0.9s, setup paths: 1.7s, initialize shared: 0.2s, other imports: 0.4s, load scripts: 0.3s, create ui: 0.6s, gradio launch: 0.3s).Applying attention optimization: Doggettx... done.Model loaded in 2.3s (load weights from disk: 0.8s, create model: 0.3s, apply weights to model: 0.2s, load textual inversion embeddings: 0.6s, calculate empty prompt: 0.3s).

这里必须要踩一下MobaXterm(夸一下vscode),MobaXterm终端里一直卡在这里,一开始我以为是再等结果,主要它也没报错,结果其实它已经结束了,可以点这个URL在本地运行了,害我等了好久。但是MobaXterm没那么智能,好像是有个服务器与客户机的转发问题,直接点这个URL打不开。退一步讲可以远程连接服务器桌面在浏览器打开这个URL。

vscode就好多了,运行完直接自动给我打开网址!


点击全文阅读


本文链接:http://zhangshiyu.com/post/93952.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1