在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、初步运行

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

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

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

相关推荐
love530love16 小时前
【避坑指南】提示词“闹鬼”?Stable Diffusion 自动注入神秘词汇 xiao yi xian 排查全记录
人工智能·windows·stable diffusion·model keyword
世界尽头与你16 小时前
Stable Diffusion web UI 未授权访问漏洞
安全·网络安全·stable diffusion·渗透测试
love530love16 小时前
【故障解析】Stable Diffusion WebUI 更换主题后启动报 JSONDecodeError?可能是“主题加载”惹的祸
人工智能·windows·stable diffusion·大模型·json·stablediffusion·gradio 主题
ai_xiaogui5 天前
Stable Diffusion Web UI 绘世版 v4.6.1 整合包:一键极速部署,深度解决 AI 绘画环境配置与 CUDA 依赖难题
人工智能·stable diffusion·环境零配置·高性能内核优化·全功能插件集成·极速部署体验
微学AI6 天前
金仓数据库的新格局:以多模融合开创文档数据库
人工智能·stable diffusion
我的golang之路果然有问题6 天前
开源绘画大模型简单了解
人工智能·ai作画·stable diffusion·人工智能作画
我的golang之路果然有问题7 天前
comfyUI中的动作提取分享
人工智能·stable diffusion·ai绘画·人工智能作画·comfy
stephen one10 天前
2026 AI深度伪造危机:实测 Midjourney v7 与 Flux 2 Max 识别,谁才是 AI 检测的天花板?
人工智能·ai作画·stable diffusion·aigc·midjourney
长不大的蜡笔小新13 天前
基于Stable Diffusion的多模态图像生成与识别系统
stable diffusion
米汤爱学习14 天前
stable-diffusion-webui【笔记】
笔记·stable diffusion