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

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

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

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

相关推荐
wei_shuo1 天前
GpuGeek 实操指南:So-VITS-SVC 语音合成与 Stable Diffusion 文生图双模型搭建,融合即梦 AI 的深度实践
人工智能·stable diffusion·gpu算力·gpuseek
这是一个懒人3 天前
Stable Diffusion WebUI 插件大全:功能详解与下载地址
stable diffusion
浪淘沙jkp3 天前
AI大模型学习十八、利用Dify+deepseekR1 +本地部署Stable Diffusion搭建 AI 图片生成应用
人工智能·stable diffusion·agent·dify·ollama·deepseek
Icoolkj4 天前
深入了解 Stable Diffusion:AI 图像生成的奥秘
人工智能·stable diffusion
这是一个懒人5 天前
mac 快速安装stable diffusion webui
macos·stable diffusion
璇转的鱼5 天前
Stable Diffusion进阶之Controlnet插件使用
人工智能·ai作画·stable diffusion·aigc·ai绘画
AloneCat20126 天前
stable Diffusion模型结构
stable diffusion
西西弗Sisyphus6 天前
Stable Diffusion XL 文生图
stable diffusion
霍志杰7 天前
stable-diffusion windows本地部署
windows·stable diffusion
昨日之日20067 天前
ACE-Step - 20秒生成4分钟完整歌曲,音乐界的Stable Diffusion,支持50系显卡 本地一键整合包下载
计算机视觉·stable diffusion·音视频