ComfyUI 本地部署精华指南(Windows + CUDA)

ComfyUI 本地部署精华指南(Windows + CUDA)

适用环境:Windows 10/11,NVIDIA GPU(如 RTX 4080),支持 CUDA 12.1+


一、创建 Conda 环境

powershell 复制代码
conda create -n comfy python=3.10 -y
conda activate comfy

建议使用清华镜像源加速(已在你的配置中启用)。


二、克隆 ComfyUI 源码

由于 GitHub 访问不稳定,推荐使用 Gitee 镜像:

powershell 复制代码
git clone https://gitee.com/weifuzi0217/ComfyUI.git
cd ComfyUI

三、安装依赖(关键:必须用 CUDA 版本 PyTorch)

❌ 错误做法(会安装 CPU-only 版本):

bash 复制代码
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple

✅ 正确做法(指定 cu121 官方源):

方法 1:直接从 PyTorch 官方下载(推荐)
powershell 复制代码
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu121

若网络慢,可先手动下载 .whl 文件(链接),再本地安装:

powershell 复制代码
pip install torch-2.4.0+cu121-cp310-cp310-win_amd64.whl ...
方法 2:验证是否成功
python 复制代码
python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
# 应输出:2.4.0+cu121 True

安装其余依赖(使用清华源加速):

powershell 复制代码
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

四、启动 ComfyUI

powershell 复制代码
python main.py

成功启动后,终端将显示:

复制代码
To see the GUI go to: http://127.0.0.1:8188

打开浏览器访问即可使用。


五、常见问题解决

问题 原因 解决方案
AssertionError: Torch not compiled with CUDA enabled 安装了 CPU 版 PyTorch 卸载后重装 cu121 版本
git clone 失败 GitHub 网络限制 改用 Gitee 镜像或代理
启动卡住/无响应 显存不足或驱动不兼容 确保 NVIDIA 驱动 ≥ 535,CUDA ≥ 12.1

六、附:环境信息(供参考)

  • GPU: NVIDIA GeForce RTX 4080 SUPER
  • Driver: 561.09
  • CUDA Version: 12.6(向后兼容 cu121)
  • Python: 3.10
  • PyTorch: 2.4.0+cu121
  • ComfyUI: v0.4.0

✅ 完成以上步骤,即可在本地高效运行 ComfyUI,充分利用 GPU 加速。

相关推荐
敏编程21 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪21 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook1 天前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田1 天前
使用 pkgutil 实现动态插件系统
python
前端付豪2 天前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽2 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战2 天前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋2 天前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者3 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者3 天前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python