logo
0
0
Login

ComfyUI Demo

官方文档:ComfyUI Official Documentation - ComfyUI

一、镜像相关命令

# 当前推送的制品名与制品所在的仓库名一致 docker build -f .ide/Dockerfile -t docker.cnb.cool/smk2h/comfyui-demo:latest . # 查看镜像 docker images # 运行镜像 docker run -it -p 8188:8188 docker.cnb.cool/smk2h/comfyui-demo:latest # 推送镜像 docker push docker.cnb.cool/smk2h/comfyui-demo:latest

二、ComfyUI 的安装

1. Python 环境

运行 ComfyUI 是需要 Python 环境的,同时也需要安装 cuda,torch 等的环境,我们可以使用 pytorch 的镜像源作为基础镜像,这里选择的是cuda13.0 torch2.9.0 版本的镜像,在 Dockerfile 中可写:

# 官方源 FROM pytorch/pytorch:2.9.0-cuda13.0-cudnn9-devel # 项目镜像源 FROM docker.cnb.cool/pylover/docker/pytorch:2.9.0-cuda13.0-cudnn9-devel

2. 安装 ComfyUI

在 CNB 中启动云环境默认是初始的镜像,是没有 ComfyUI 应用在里面的,因此我们需要自定义一个 Dockerfile 定义本环境的启动环境,通过使用 git 命令拉取 ComfyUI 的官方仓库到指定文件夹 /ComfyUI

# 安装 ComfyUI git clone https://github.com/comfyanonymous/ComfyUI.git /ComfyUI # 安装依赖 cd ComfyUI pip install -r requirements.txt

如果是在Dockerfile中,则可以这样写:

# 安装 ComfyUI RUN git clone https://github.com/comfyanonymous/ComfyUI.git /ComfyUI # 指定工作目录 WORKDIR /ComfyUI # 安装 ComfyUI 的依赖 RUN pip install -r requirements.txt

3. ComfyUI 的插件安装

安装插件只需要在 ComfyUI 里插件搜索页面安装即可,但是由于 CNB 的特殊性,通过这种方法安装的插件在下次打开仓库云环境时是不会保存的,因此这里我们使用 git 命令安装插件,在自定义云环境的 Dockerfile 中可添加如下:

# 安装 ComfyUI-Manager 插件 RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git /ComfyUI/custom_nodes/ComfyUIManager

安装完成插件后,也需要在插件目录 /ComfyUI/custom_nodes/ComfyUIManager 内使用命令安装 requirements.txt 内的依赖,否则插件将可能加载不成功。

三、模型下载

ComfyUI 的运行是需要各种各样的模型的,本项目最推荐的模型下载地址是 CNB 的官方模型仓库:ai-models,下载方式在仓库的主页有介绍,当然本项目还提供了其他的下载方式:

# 创建放模型的文件夹 mkdir -p /ComfyUI/models/vae # 使用 aria2 下载仓库模型 aria2c -x16 -s16 -j16 -c -o ae.safetensors -d /ComfyUI/models/vae https://cnb.cool/ai-models/camenduru/FLUX.1-dev/-/lfs/afc8e28272cd15db3919bacdb6918ce9c1ed22e96cb12c4d5ed0fba823529e38?name=ae.safetensors

aria2c 命令基本格式如下:

aria2c [参数] -d 下载目录 "下载URL"

当然如果有其他的模型需求,可前往 huggingface | modelscope 下载。

About

comfyui学习仓库

Language
Shell59.2%
Dockerfile40.8%