在Ubuntu22.04上部署ComfyUI

ComfyUI 是 一个基于节点流程的 Stable Diffusion 操作界面,可以通过流程,实现了更加精准的工作流定制和完善的可复现性。每一个模块都有特定的的功能,我们可以通过调整模块连接达到不同的出图效果,特点如下:

1.对显存要求相对较低,启动速度快,出图速度快;

2.具有更高的生成自由度;

3.可以和 webui 共享环境和模型;

4.可以搭建自己的工作流程,可以导出流程并分享给别人,报错的时候也能清晰的发现错误出在哪一步;

5.生成的图片拖进后会还原整个工作流程,模型也会选择好。

一:环境准备

PVE4.17构建虚拟机系统

配置虚拟机:32GB内存,至少颗CPU

添加Nvidia P40 24G 一片

虚拟机中安装Ubuntu 22.04

设置Ubuntu22.04IP为192.168.29.81

参照下面的步骤,开始安装配置工作环境:

复制代码
#1、安装gcc和g++
sudo apt update
sudo apt install gcc g++

#查看版本
gcc --version
g++ --version

#2、安装make
sudo apt install make
sudo apt install make-guile

#查看make版本
make -v

#3、安装N卡驱动
#首先,编辑黑名单配置。

vim /etc/modprobe.d/blacklist.conf

#在文件的最后添加下面两行。

blacklist nouveau
options nouveau modeset=0

#然后,输入下面的命令更新并重启。
update-initramfs -u
reboot
#重启后输入下面的命令验证是否禁用成功,成功的话这行命令不会有输出。

lsmod | grep nouveau

#驱动安装
#首先,使用apt卸载已有的驱动,命令如下。

apt-get purge nvidia*

#进入驱动所在路径,赋予执行权限,并执行安装命令

chmod +x NVIDIA-Linux-x86_64-535.86.05.run
./NVIDIA-Linux-x86_64-535.86.05.run

#注:具体文件根据下载的驱动来填写
nvidia-smi

#4、安装cuda和cuDNN
#安装zlib软件包
apt-get install zlib1g

#重启服务器后,如不生效,可直接将文件写在.bashrc里面
vim ~/.bashrc
#添加以下几句:

PATH=$PATH:/usr/local/cuda/bin  
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64  
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64

#使生效
source ~/.bashrc

#cuDNN下载地址:
https://developer.nvidia.com/rdp/cudnn-archive

#tar包方式
xz -d cudnn-linux-x86_64-8.9.4.25_cuda12-archive.tar.xz
tar -xvf cudnn-linux-x86_64-8.9.4.25_cuda12-archive.tar

cp /root/cudnn-linux-x86_64-8.9.4.25_cuda12-archive/include/cudnn.* /usr/local/cuda/include/
cp /root/cudnn-linux-x86_64-8.9.4.25_cuda12-archive/lib/* /usr/local/cuda/lib64
chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

#5、安装anaconda
bash ./Anaconda3-2023.09-0-Linux-x86_64.sh

二:部署ComfyUI

1:下载代码仓库

复制代码
git clone https://github.com/comfyanonymous/ComfyUI.git

2、创建虚拟环境

复制代码
conda create -n comfyui python=3.10
conda activate comfyui

3、安装pytorch和相关依赖

复制代码
#安装pytorch
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simpl
pip3 install torch torchvision torchaudio

#安装相关依赖
pip install -r requirements.txt

4、修改配置文件

复制代码
cp extra_model_paths.yaml.example  extra_model_paths.yaml

编辑 extra_model_paths.yaml

修改checkpoints的路径和其他模型路径,请根据你实际放置位置来修改:

复制代码
vim extra_model_paths.yaml

a111:
    base_path: /app/ComfyUI/

    checkpoints: models/checkpoints
    configs: models/configs
    vae: models/VAE
    loras: |
         models/Lora
         models/LyCORIS
    upscale_models: |
                  models/ESRGAN
                  models/RealESRGAN
                  models/SwinIR
    embeddings: embeddings
    hypernetworks: models/hypernetworks
    controlnet: models/ControlNet

三:下载相关的大模型

1、stable-diffusion-xl-base-1.0

git clone https://www.modelscope.cn/AI-ModelScope/stable-diffusion-xl-base-1.0.git

2、stable-diffusion-xl-refiner-1.0

git clone https://www.modelscope.cn/AI-ModelScope/stable-diffusion-xl-refiner-1.0.git

3、stable-diffusion-v1.5

git clone https://www.modelscope.cn/AI-ModelScope/stable-diffusion-v1.5-no-safetensor.git

模型百度下载:

链接:https://pan.baidu.com/s/1Xl1NCE8AT5V7nu3I-YF_BA?pwd=i2pa

提取码:i2pa

四:启动comfyui

复制代码
python main.py --port 8188 --listen 192.168.29.81

五:插件安装

复制代码
cd ComfyUI/custom_nodes
#直接克隆

git clone https://github.com/AIGODLIKE/AIGODLIKE-COMFYUI-TRANSLATION
git clone https://github.com/twri/sdxl_prompt_styler
git clone https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet
git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts
git clone https://github.com/ltdrdata/ComfyUI-Manager.git

插件说明

辣椒酱的界面汉化: https://github.com/AIGODLIKE/AIGODLIKE-COMFYUI-TRANSLATION

提示词风格样式: https://github.com/twri/sdxl_prompt_styler

提示词中文输入: https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet

小瑞士军刀美化辅助: https://github.com/pythongosssss/ComfyUI-Custom-Scripts

ComfyUI Manager:https://github.com/ltdrdata/ComfyUI-Manager.git

六:ComfyUI使用方法

1、修改中语言

在语言处选择中文。

2、初步运行

在默认加载页面,我们可以初步运行一个测试如下图:

选择一个模型,然后上传一张照片。

下一节我们再详细介绍其他设置。

相关推荐
AI绘画咪酱21 小时前
【CSDN首发】Stable Diffusion从零到精通学习路线分享
人工智能·学习·macos·ai作画·stable diffusion·aigc
源客z3 天前
Stable Diffusion +双Contronet:从 ControlNet 边缘图到双条件融合:实现服装图像生成的技术演进——项目学习记录
图像处理·人工智能·计算机视觉·stable diffusion
AIGC-Lison4 天前
Stable Diffusion ComfyUI 基础教程(一) ComfyUI安装与常用插件
人工智能·stable diffusion·教程·ai绘画·sd·sd教程
shangyingying_14 天前
关于AIGC stable diffusion 在图像超分上的算法整理
stable diffusion·aigc
XD7429716364 天前
Stable Diffusion:使用ControlNet为黑白照片上色
stable diffusion
未来之窗软件服务9 天前
Stable Diffusion win10 Cpu安装日志
stable diffusion
xuebodx09239 天前
私有部署stable-diffusion-webui
图像处理·pytorch·ai作画·stable diffusion·视觉检测·transformer·dall·e 2
AIGC_ZY9 天前
Stable Diffusion XL、SD3 与 Flux 模型常用优化器总结
stable diffusion
在线打码10 天前
Dify + Stable Diffusion实现文生图工作流【两种方式】
ai·ai作画·stable diffusion·aigc·dify
曲幽10 天前
Python本地部署Stable Diffusion实现在纯CPU环境下的实现
python·ai·stable diffusion·cpu·openvino·lcm