这里使用 Anaconda3 管理 Python 环境,目的是为了避免 Python 项目共用环境导致的依赖冲突等一系列问题。下载页面 Download Anaconda Distribution | Anaconda - https://www.anaconda.com/download。
百度网盘下载链接 Anaconda3-2024.10-1-Windows-x86_64.exe - https://pan.baidu.com/s/1itL6cu8KmEIlBCXsFdt7yA?pwd=25mw
检查 Python 是否安装成功,这里懒得折腾环境变量,这里在开始才到找到并打开 Anaconda Prompt
运行后续命令。
Git 客户端用于从 github.com
上下载和更新 ComfyUI 仓库源码。下载页面 Git - Downloads - https://git-scm.com/downloads。
百度网盘下载链接 Git-2.47.1.2-64-bit - https://pan.baidu.com/s/1lQ_AugwOLCrZQYa5OplwFg?pwd=7cjt
检查 Git 是否安装成功。
没有安装 ComfyUI 官方的桌面版 (Download ComfyUI for Windows/Mac - https://www.comfy.org/download) 的主要原因是感觉不太稳定,重启电脑后总会有一些问题,所以这里从 github.com
下载仓库源码的方式部署。
GitHub - comfyanonymous/ComfyUI: The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. - https://github.com/comfyanonymous/ComfyUI
克隆到本地 D 盘 D:\github.com
目录下。
1git clone https://github.com/comfyanonymous/ComfyUI.git
新建一个 ComfyUI-Python3.12-GPU
的 Python 虚拟环境。
1conda create -n ComfyUI-Python3.12-GPU python=3.12
激活虚拟环境,注意看红框由 (base)
变成 (ComfyUI-Python3.12-GPU)
表示成功切换 Python 环境。
1conda activate ComfyUI-Python3.12-GPU
本机为 NVIDIA 显卡,先查看显卡支持的 CUDA 版本为 12.7
,安装 pytorch
的版本可小于等于 12.7
。
1nvidia-smi
到 pytorch
网站 Start Locally | PyTorch - https://pytorch.org/get-started/locally/ 查看最新支持版本为 12.6
。
1pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
安装后报错,到页面 Previous PyTorch Versions | PyTorch - https://pytorch.org/get-started/previous-versions/ 找到更低版本为 12.4.
1pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
如果后面 ComfyUI 启动提示 AssertionError: Torch not compiled with CUDA enabled
的错误,可先删除 pytorch
。
1pip uninstall torch -y
重新安装 pytorch
,因为已经安装过,返回的信息提示是当前环境中相关依赖包及版本已经满足需求,首次安装会自动下载安装。
1pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
安装其他依赖,同样因为已经安装过,返回的信息与首次安装不一样。
1cd ComfyUI
2pip install -r requirements.txt
如果想删除相关包,可用命令
pip uninstall -r requirements.txt
如果想强制更新,可用命令pip install --upgrade -r requirements.txt
Janus-Pro 的节点有好几位作者都发布了,这里以安装 ComfyUI-Janus-Pro 节点为例。
1git clone https://github.com/CY-CHENYUE/ComfyUI-Janus-Pro.git
为了方便后面的管理,更推荐 ComfyUI-Manager 安装的方式。当然命令行方式更灵活,例如某些节点在 ComfyUI-Manager 搜索不到的的时候。
1cd custom_nodes
2git clone https://github.com/ltdrdata/ComfyUI-Manager.git
当然也可以启动 ComfyUI 后,通过 ComfyUI-Manager 进行安装。
1cd ..
2python main.py
打开浏览器访问 http://127.0.0.1:8188/
,可看到 ComfyUI-Manager 工具栏。
点开节点管理。
搜索 Janus
发现有好几个几点可用,这里选择安装 ComfyUI-Janus-Pro 节点。
为了加速下载,建议按以下步骤操作。
按下快捷键 win+x
,打开菜单项 系统
。
选择 高级系统设置
。
选择 环境变量
新建一个名为 HF_ENDPOINT
,值为 https://hf-mirror.com
的 用户变量
,用 系统变量
新建也是可以的。
设置完成后关掉 Anaconda Prompt
窗口后重新打开,查看环境变量是否已生效。
1echo %HF_ENDPOINT%
如果没有显示任何内容,或者在后续下载模型的时候报 huggingface.co
连接超时,重启电脑让环境变量生效。
先安装抱抱脸下载客户端工具 huggingface-hub
,部分网文写的是 huggingface-cli
,也许是 Python 版本不一样的问题或者就是写错,不深究。
1pip install huggingface-hub
抱抱脸上 deepseek-ai (DeepSeek) - https://huggingface.co/deepseek-ai 有 Janus-Pro-1B
和 Janus-Pro-7B
两个版本,都下载下来试试效果。
下载 Janus-Pro-1B
:
1huggingface-cli download deepseek-ai/Janus-Pro-1B --local-dir D:\github.com\ComfyUI\models\Janus-Pro\Janus-Pro-1B --resume-download --local-dir-use-symlinks False
下载 Janus-Pro-7B
:
1huggingface-cli download deepseek-ai/Janus-Pro-7B --local-dir D:\github.com\ComfyUI\models\Janus-Pro\Janus-Pro-7B --resume-download --local-dir-use-symlinks False
用节点作者提供的工作流测试,一个节点用于文生图,另一个节点用于反推图片提示词。
1cute anime girl with massive fluffy fennec ears and a big fluffy tail blonde messy long hair blue eyes wearing a maid outfit with a long black gold leaf pattern dress and a white apron mouth open holding a fancy black forest cake with candles on top in the kitchen of an old dark Victorian mansion lit by candlelight with a bright window to the foggy forest and very expensive stuff everywhere
Flux Dev
原图:Janus-Pro-1B
效果(384x384):Janus-Pro-7B
效果(384x384):1A portrait photo of a girl
Janus-Pro-1B
效果(384x384):Janus-Pro-7B
效果(384x384):初步体验如上。