ComfyUI 安装与启动步骤(Windows + NVIDIA GPU)

环境:Windows 11 / Python 3.10 / NVIDIA RTX系列显卡


1. 克隆仓库

git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI

2. 创建并激活虚拟环境

必须在 ComfyUI 文件夹内创建,不要建在 E 盘根目录或其他位置。

cd E:\ComfyUI
python -m venv .venv
.venv\Scripts\activate

激活后命令提示符前面会显示 (.venv)。


3. 升级 pip

python -m pip install --upgrade pip

4. 安装 PyTorch(CUDA 12.8)

pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 --index-url https://download.pytorch.org/whl/cu128 --no-cache-dir --retries 10 --timeout 300

注意:

  • 必须用 --index-url(不是 --extra-index-url),否则 pip 会去 PyPI 下载 CPU 版
  • 文件约 3.3GB,如果网络中断,重新执行同一命令即可续传

验证 GPU 是否可用:

python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"

必须输出:

2.7.0+cu128
True

如果输出 False 或没有 +cu128,说明是 CPU 版,需卸载重装。


5. 安装 ComfyUI 依赖

pip install -r requirements.txt

如果下载慢,可用国内镜像:

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

6. 启动 ComfyUI

必须在 E:\ComfyUI 目录下执行,因为 main.py 是相对路径。

cd E:\ComfyUI
.venv\Scripts\activate
python main.py

启动成功后终端显示:

Starting server
To see the GUI go to: http://127.0.0.1:8188

浏览器访问:

http://127.0.0.1:8188

7. 快捷启动(可选)

每次手动输入命令比较麻烦,可以在桌面新建 启动ComfyUI.bat:

@echo off
cd /d E:\ComfyUI
call .venv\Scripts\activate
python main.py
pause

以后双击该文件即可直接启动,无需手动开终端。


8. 常见问题速查

错误 原因 解决
AssertionError: Torch not compiled with CUDA enabled 安装了 CPU 版 PyTorch 用 --index-url 重新安装 GPU 版
No such file or directory: 'main.py' 不在 ComfyUI 目录内 先执行 cd E:\ComfyUI
No such file or directory: 'requirements.txt' 不在 ComfyUI 目录内 先执行 cd E:\ComfyUI
No module named 'torch' 虚拟环境里没装 torch 确认已激活 .venv 并重新安装
Connection interrupted while downloading 网络不稳定 加 --retries 10 --timeout 300,或换网络时段重试
comfy_kitchen 相关报错 版本不兼容 pip install comfy-kitchen==0.2.31
posted @ 2026-09-01 10:50  RK5123153  阅读(104)  评论(0)    收藏  举报