Ubuntu18.04本地部署Stable-Diffusion-webui绘画

这篇具有很好参考价值的文章主要介绍了Ubuntu18.04本地部署Stable-Diffusion-webui绘画。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

记录Ubuntu下安装Stable-Diffusion-webui,比较简单,以供参考。

系统:Ubuntu 18.04.4 LTS
内存:40G
显卡:32G
硬盘:500G

一、安装cuda

支持安装的cuda版本可以用nvidia-smi命令查看:
 

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.182.03   Driver Version: 470.182.03   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla V100-SXM2...  Off  | 00000000:00:08.0 Off |                    0 |
| N/A   39C    P0    55W / 300W |      0MiB / 32510MiB |      3%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+


显卡驱动支持的cuda版本最高是11.4,可以在这里下载对应的cuda版本:CUDA Toolkit Archive | NVIDIA Developer(https://developer.nvidia.com/cuda-toolkit-archive)。由于之前安装别的环境,已经装了cuda11.4版本,可以用nvcc -V查看安装的cuda版本。


二、搭建python虚拟环境(为了不影响原系统环境)

使用miniconda,我之前已经安装了。然后使用conda创建虚拟环境sdwebui,使用的python版本为3.10.9(stable-diffusion-webui用的python版本为3.10.6)。

conda create -n sdwebui python==3.10.9

激活环境

conda activate sdwebui

升级pip并更改默认库包下载地址为清华镜像(如果已经有镜像的可以忽略)

    python -m pip install --upgrade pip
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

安装torch

在pytorch官网Previous PyTorch Versions | PyTorch(https://pytorch.org/get-started/previous-versions/) 官网不能访问的可以打开:Pytorch和CUDA版本对应关系_TURING.DT的博客-CSDN博客

查看对应的cuda支持的torch版本,并且直接拷贝安装命令。

这里是我的cuda版本对应的安装命令。

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch


三、下载并安装stable-diffusion-webui

切换到当前用户目录下,使用git命令下载stable-diffusion-webui源码

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

由于国内github不能稳定连接,所以可以从国内的gitee(码云)下载

git clone https://gitee.com/yiouyou/automatic1111-stable-diffusion-webui.git

打开v2-1_768-ema-pruned.ckpt · stabilityai/stable-diffusion-2-1 at main(https://huggingface.co/stabilityai/stable-diffusion-2-1/blob/main/v2-1_768-ema-pruned.ckpt),下载训练模型(大小4.9G)。下载完成后,把v2-1_768-ema-pruned.ckpt这个训练模型放入stable-diffusion-webui的models/Stable-diffusion目录下,这个目录专门存放用于生成AI绘图的绘图元素的基础模型库。后续如果在其他网站比如civitai之类的地方下载的ckpt或者safetensors文件也是放在这个文件夹里面。


然后切换到webui目录下,安装依赖

    cd stable-diffusion-webui/
    pip install -r requirements_versions.txt
    pip install -r requirements.txt

安装完成后,启动stable-diffusion-webui

python launch.py

这里要安装很多依赖,并且要git clone相关包和模型文件,需要科学上网,否则会失败。

最终启动成功后如下图所示,会出来一个url:

(sdwebui) ubuntu@VM-16-ubuntu:~/sdwebui/stable-diffusion-webui$ python launch.py

Python 3.10.9 (main, Mar  8 2023, 10:47:38) [GCC 11.2.0]
Version: v1.4.0
Commit hash: 394ffa7b0a7fff3ec484bcd084e673a8b301ccc8
Installing clip
Installing open_clip
Cloning Stable Diffusion into /home/ubuntu/sdwebui/stable-diffusion-webui/repositories/stable-diffusion-stability-ai...
Cloning K-diffusion into /home/ubuntu/sdwebui/stable-diffusion-webui/repositories/k-diffusion...
Cloning CodeFormer into /home/ubuntu/sdwebui/stable-diffusion-webui/repositories/CodeFormer...
Cloning BLIP into /home/ubuntu/sdwebui/stable-diffusion-webui/repositories/BLIP...
Installing requirements for CodeFormer
Installing requirements
Launching Web UI with arguments:
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-9vmy3hxk because the default path (/home/ubuntu/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
No module 'xformers'. Proceeding without it.
==============================================================================
You are running torch 1.12.1.
The program is tested to work with torch 2.0.0.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.

Use --skip-version-check commandline argument to disable this check.
==============================================================================
Calculating sha256 for /home/ubuntu/sdwebui/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-ema-pruned.ckpt: preload_extensions_git_metadata for 7 extensions took 0.00s
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 7.8s (import torch: 1.6s, import gradio: 1.5s, import ldm: 0.4s, other imports: 3.2s, load scripts: 0.5s, create ui: 0.5s).
ad2a33c361c1f593c4a1fb32ea81afce2b5bb7d1983c6b94793a26a3b54b08a0
Loading weights [ad2a33c361] from /home/ubuntu/sdwebui/stable-diffusion-webui/models/Stable-diffusion/v2-1_768-ema-pruned.ckpt
Creating model from config: /home/ubuntu/sdwebui/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/configs/stable-diffusion/v2-inference-v.yaml
LatentDiffusion: Running in v-prediction mode
DiffusionWrapper has 865.91 M params.
Applying attention optimization: Doggettx... done.


在浏览器打开这个url,表示环境部署成功。


四、使用stable-diffusion-webui

注意:如果在prompt输入后点击generate无法生成图片,看见黑色小框显示“float 32“之类的关键字,则在webui 页面的 Settings->StableDiffusion 最下面,勾选 float32 的选项框。接着点击上方的Apply settings 应用,然后按F5刷新页面后,即可正常使用。

在左上角的文本框prompt输入提示词,点击Generate,等待数秒钟(我的电脑大概等待15s左右),就会生成一张图。

Ubuntu18.04本地部署Stable-Diffusion-webui绘画,大模型,stable diffusion,AI作画

默认端口是7860,如果想换端口 启动时加参数:python launch.py --port 7770文章来源地址https://www.toymoban.com/news/detail-516384.html

到了这里,关于Ubuntu18.04本地部署Stable-Diffusion-webui绘画的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • DockerFile文件部署Ubuntu18.04、Ros melodic、SLambook2的编译详细攻略

            最近,在Ubuntu系统上跑各种项目,经常出现环境配置干扰问题,导致项目常年无法运行。因此,查询各种方法,最终采用使用Docker来解决此问题,并成功运行 Rviz和Gazebo!!!         以下,为本人在配置、编写DockerFile文档时候遇到的一些问题。        

    2024年01月20日
    浏览(32)
  • Ubuntu18.04跑通ORB_SLAM3(实时USB单目摄像头&本地视频.mp4&官方数据集)

    本人小白,寒假期间学习了一些ROS知识,试着在虚拟机搭建ORB_SLAM3环境并跑通数据集和摄像头,作本文以记录学习过程。所有用到的资源(软件安装包,镜像文件,库的源码文件都会放在最后百度网盘链接里) 目录 0.something you should know 1.安装VMware Workstation Pro和Ubuntu18.04 2.安

    2023年04月18日
    浏览(54)
  • Linux系统 Ubuntu18.04安装的详细教程(提供18.04ubuntu镜像)

    镜像文件下载: 链接:https://pan.baidu.com/s/12bEdRBwO1YbLt23QKnrSrA 提取码:h7as 关于全名、用户名区别可先看第四部分 处理器和内核数量,根据需要配置就行。我是8核16线程,配置2,2。小白学习的话,配置低一点没关系。如果你只是为了学一些基础命令,配置成1,1应该也没问题

    2024年02月01日
    浏览(48)
  • Ubuntu18.04 升级Ubuntu20.04

    因项目环境需要,欲将Ubuntu18.04升级至Ubuntu20.04,参考网上其他小伙伴的方法,也遇到了一个问题,特此记录一下,希望能帮助其他有同样问题的小伙伴。 参考:第十五章 Ubuntu18.04LTS升级到20.04LTS 主要的步骤: 在执行“do-release-upgrade”时,遇到“Failed to connect to https://changel

    2024年02月02日
    浏览(42)
  • Ubuntu(18.04)换源

    主要参考Ubuntu(18.04)更换国内源方法及注意事项_muxi_712的博客-CSDN博客 为防止其删除博客,本文简单重新梳理一遍: 跳转: 查看: 备份: 替换: 这里使用清华源:打开https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/,选择对应的Ubuntu版本。当然也可以选择其他源比如阿里源,中科大源

    2024年02月04日
    浏览(40)
  • ubuntu18.04环境搭建

    sudo apt install make sudo apt install make-guile 运行Ubuntu的主机 打开终端,输入【sudo apt update】命令。 输入密码,确认授权。 输入【sudo apt install git】命令。 输入【Y】,确认命令执行。 输入【git --version】命令,查看安装版本。 Git当前版本为【2.30.2】,就此安装完成。 打开Ubuntu终端

    2023年04月22日
    浏览(93)
  • ubuntu 18.04网络问题

    安装好系统之后,检查gcc和make是否已经安装 如果未安装,则安装gcc和make 安装openssh-server 安装网络工具和防火墙 开通端口 准备设置静态IP时,发现没有有线网卡,无法正常插网线进行联网。 执行ipconfig 查看网卡配置是否有 ethxx 或者 enxx ,也没有,则说明有线网卡的驱动需要

    2024年01月25日
    浏览(33)
  • Ubuntu 18.04分区方案

    先分逻辑分区后面在分主分区 【 不需要全部设为主分区 ,只需要第一个设为主分区;各个分区大小根据情况自己定义】 目录 分区 建议大小 格式 描述 是否可选 / 主分区 100G ext4 根目录,用于存放系统,相当于c 盘 安装系统和软件 必选 /home 逻辑分区 尽量大 ext4 相当于我的

    2024年02月04日
    浏览(29)
  • Ubuntu 18.04开发环境搭建

            工作不易,为了避免未来需要重装系统的进行折腾,个人进行了Ubuntu环境配置的整合,方便自己未来能顺畅的配置好开发环境,同时分享给大家。本文多出有转载其他文,并相应的标注了转载内容,如有侵权请联系博主删除。 vmware下载: 链接:https://pan.baidu.com

    2024年02月02日
    浏览(40)
  • ubuntu 18.04安装docker

    from:Install Docker Engine on Ubuntu | Docker Documentation Install from a package If you can’t use Docker’s  apt  repository to install Docker Engine, you can download the  deb  file for your release and install it manually. You need to download a new file each time you want to upgrade Docker Engine. Go to Index of linux/ubuntu/dists/. Select your

    2024年02月05日
    浏览(53)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包