ComfyUI Windows Anaconda 环境部署与配置完整笔记

一、环境部署状态

1.1 部署成功确认

  • Python版本:3.13.12(Anaconda环境)
  • PyTorch版本:2.10.0+cu130(支持CUDA)
  • ComfyUI版本:0.16.4
  • GPU:NVIDIA GeForce RTX 3060(12GB VRAM)
  • 启动命令:python main.py --listen 0.0.0.0 --port 8188
  • 访问地址:本地 http://127.0.0.1:8188,局域网 http://[IP地址]:8188

1.2 环境检测结果

  • 后端检测状态:cuda可用,triton已禁用,eager可用
  • VRAM状态:NORMAL_VRAM
  • 显存管理:使用cudaMallocAsync异步显存卸载
  • 固定内存启用:29419.0 MB
  • 注意力机制:PyTorch原生注意力

二、CUDA版本查看方法

2.1 查看系统CUDA版本(nvcc)

nvcc --version

nvcc -V

2.2 查看驱动支持的最高CUDA版本

nvidia-smi

在输出表格顶部查看"CUDA Version:"字段。

2.3 查看PyTorch内置CUDA版本

在激活的Conda环境中执行:

import torch
print(torch.__version__)          # 查看PyTorch版本
print(torch.version.cuda)         # 查看PyTorch编译时依赖的CUDA版本
print(torch.cuda.is_available())  # 确认CUDA是否可用,应返回True

2.4 版本一致性判断

  • 关键是系统CUDA版本与PyTorch内置CUDA版本需要匹配(同为大版本,如均为12.x或13.x)
  • 驱动支持的最高CUDA版本需大于或等于PyTorch内置CUDA版本
  • 本环境PyTorch版本为cu130(CUDA 13.0)

三、SageAttention安装评估(最终决定不安装)

3.1 安装收益

  • 在SDXL、Flux、Wan2.2等模型上可带来约2倍速度提升
  • 通过INT8/FP8量化减少显存占用

3.2 Windows环境安装挑战

  • Python 3.13兼容性:SageAttention主要测试于Python 3.10-3.12
  • 需要完整Visual Studio 2022 Build Tools和CUDA Toolkit
  • 系统CUDA需与PyTorch内置nvcc版本一致
  • 需要Triton Windows版本

3.3 最终决定

鉴于当前环境运行正常,决定不安装SageAttention,保持使用PyTorch原生注意力机制。

四、ComfyUI基础使用与插件安装

4.1 基础工作流核心节点

  1. Load Checkpoint(加载大模型):需将模型文件放入 ComfyUI\models\checkpoints\
  2. CLIP Text Encode(CLIP文本编码):正面提示词和负面提示词
  3. KSampler(K采样器):设置图片尺寸、种子、采样步数等参数
  4. VAE Decode(VAE解码)和Save Image(保存图像)

4.2 推荐基础插件

  1. ComfyUI-Manager:插件管理工具,支持一键安装、更新、禁用其他插件
  2. AIGODLIKE-COMFYUI-TRANSLATION:界面汉化
  3. ComfyUI-Crystools:电脑资源监控,实时显示CPU、内存、GPU使用情况

4.3 ComfyUI-Manager安装方法

方法一:pip安装(适用于Anaconda环境)

conda activate comfyui1
cd G:\ProgramFiles\anaconda-file\ComfyUI
pip install comfyui-manager

启动时需添加参数:

python main.py --listen 0.0.0.0 --port 8188 --enable-manager

方法二:Git克隆

cd G:\ProgramFiles\anaconda-file\ComfyUI\custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git

镜像加速地址:

git clone https://ghfast.top/https://github.com/ltdrdata/ComfyUI-Manager.git

git clone https://mirror.ghproxy.com/https://github.com/ltdrdata/ComfyUI-Manager.git

五、Comfy-Pack安装与配置

5.1 安装失败问题

错误信息:Failed to clone repo: https://github.com/bentoml/comfy-pack
原因:网络无法访问GitHub

5.2 解决安装失败的方法

方法一:Git手动克隆(推荐)

conda activate comfyui1
cd G:\ProgramFiles\anaconda-file\ComfyUI\custom_nodes
git clone https://ghfast.top/https://github.com/bentoml/comfy-pack.git

或使用镜像:

git clone https://mirror.ghproxy.com/https://github.com/bentoml/comfy-pack.git

克隆完成后重启ComfyUI。

方法二:pip安装

conda activate comfyui1
pip install comfy-pack

安装完成后启动ComfyUI(加--enable-manager参数),界面顶部会出现"Package"和"Serve"按钮。

5.3 Comfy-Pack工作流改造步骤

  1. 定义输入(Toonflow传入参数):

    • 右键 -> Add Node -> ComfyPack -> input
    • 添加StringInput(提示词)、IntInput(宽度/高度/种子)等节点
    • 将这些输入节点连接到工作流原有节点的对应输入端
  2. 定义输出(返回给Toonflow):

    • 右键 -> Add Node -> ComfyPack -> output
    • 添加ImageOutput节点
    • 将VAE Decode输出的IMAGE信号连接到ImageOutput节点
  3. 启动API服务:

    • 点击ComfyUI工具栏的"Serve"按钮
    • 保持默认端口3000
    • 点击"Start"
    • 服务地址:http://127.0.0.1:3000/generate

5.4 ComfyUI-Manager相关注意事项

  • 切勿将ComfyUI-Manager文件夹改名,否则可能导致启动错误
  • 彻底卸载:直接删除 custom_nodes\ComfyUI-Manager 文件夹
  • 临时禁用:通过Manager界面的Custom Nodes Manager点击Disable
  • 紧急禁用:编辑config.json,在disabled_nodes数组中添加"ComfyUI-Manager"

六、本地Toonflow调用Comfy-Pack配置

6.1 Toonflow基本信息

  • 本地部署地址:通常为 http://localhost:60000
  • 默认登录账号:admin,密码:admin123

6.2 配置步骤

  1. 登录Toonflow,进入"系统设置"或"AI服务配置"
  2. 填写接口地址(Base URL):http://127.0.0.1:3000
  3. API Key:如未设置认证可留空或随便填写
  4. 模型名称(Model Name):填 generate 或Comfy-Pack Serve界面定义的标识符

6.3 参数映射(关键)

  • Toonflow传参的字段名必须与Comfy-Pack中StringInput、IntInput等节点的名称完全一致
  • 例如:Toonflow的"提示词"字段需映射到StringInput节点的名称

6.4 测试命令

curl -X POST http://127.0.0.1:3000/generate \
  -H "Content-Type: application/json" \
  -d '{"prompt": "a beautiful cat", "width": 512, "height": 512, "seed": 42}' \
  --output output.png

七、模型校验和说明

7.1 提示信息含义

"First run may take a few minutes to compute model checksums, depending on the number of models"

  • 这是正常提示,非报错
  • ComfyUI首次启动或添加新模型时会计算所有模型文件的校验和
  • 用于跟踪模型版本、确保文件完整性、缓存文件信息

7.2 处理建议

  • 等待计算完成,会自动进入启动完成状态
  • 如果等待超过10分钟,按Ctrl+C终止后重新启动,会继续上次的计算
  • 如仍卡住,可暂时备份models文件夹内容,分批移回定位问题文件

标签: none

添加新评论