1、安装方式
comfyui官方文档(https://docs.comfy.org/zh-CN/installation/system_requirements)提供了桌面版、windows系统便携版、手动安装三种方式,区别如下:
1、桌面版
好处是:
1.1 工作流中缺少对应模型时,点击下载缺失模型,模型能自动下载到 ComfyUI\models\ 的对应目录下。其他2种方式会把模型下载到 “此电脑>下载” ,还要手动移到对应目录。
1.2 有个C++的库。有些python库的运行需要C编译器,因此python控制台报错缺少framework某个版本的组件,无论是google搜索还是问deepseek,chatgpt,都无法单独安装这个组件,最后的解决办法是安装Visual Studio这个代码编辑工具,然后安装其中的核心组件(并且还不能删除有个叫做win11的模块,虽然我是win10系统,以为win11这个模块不安装也行,结果不安装它还是报错,所以安默认的安装就好)。Visual Studio及组件整个需要占用C盘9G。
坏处是:就算安装时设置comfyui安装到非C盘,安装完成后C盘也会占用5个G的空间。
就一个python环境,以后安装的组件有冲突时解决起来麻烦。
2、windows系统便携版
自带一个python,安装的python库也都在这个python文件夹中,你把它放哪个盘他就在哪,完全不会影响C盘。缺点是就一个python环境。
3、手动安装
好处是可以自己通过conda指定python环境。你可以安装多个comfyui,通过配置extra_model_paths.yaml文件实现模型共享,但custom_nodes中的组件各自独立,这能完全解决不同组件pip中版本冲突问题。下面是手动安装的完整过程及快捷启动脚本
找个盘,打开git bash,克隆comfyui项目
注意要给git配置代理
git config --global http.proxy "http://127.0.0.1:12345"
git config --global https.proxy "http://127.0.0.1:12346"
验证代理是否生效
git config --global --get http.proxy
git config --global --get https.proxy
克隆项目
git clone https://github.com/comfyanonymous/ComfyUI.git
取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
----------------------------------------------------
克隆完comfyui项目,用anconda创建虚拟环境
打开开始菜单,运行Anaconda Powershell Prompt,执行以下操作:
创建虚拟环境
conda create --name comfyui1 python=3.12
激活虚拟环境
conda activate comfyui1
切换到comfyui目录,安装对应python库
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
pip install -r requirements.txt
通过运行 python main.py 启动 ComfyUI
----------------------------------------------------
为了启动方便,把下面的命令保存为run_comfyui1.bat文件
@echo off
REM 1. 激活conda环境
call conda activate comfyui1
if %errorlevel% neq 0 (
echo [错误] 无法激活conda环境 'comfyui1',请检查环境是否存在
pause
exit /b 1
)
REM 2. 切换到ComfyUI目录
cd /d D:\AI\ComfyUI
if %errorlevel% neq 0 (
echo [错误] 无法切换到目录 D:\AIGC\github\ComfyUI
pause
exit /b 1
)
REM 3. 启动ComfyUI
echo 正在启动ComfyUI...
start "" python main.py
REM 4. 等待10秒确保服务启动(根据实际需要调整时间)
timeout /t 10 >nul
REM 5. 自动打开浏览器
start "" "http://127.0.0.1:8188"
echo ComfyUI已启动,浏览器已打开 http://127.0.0.1:8188
----------------------------------------------------
如果要搞新环境,只需要打开Anaconda PowerShell Prompt,执行
conda create --name comfyui2 python=3.12
conda activate comfyui2
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
pip install -r requirements.txt
复制run_comfyui1.bat为run_comfyui2.bat
把run_comfyui2.bat里的comfyui1改为comfyui2
保存运行即可。
2、针对手动安装方式,配置多个comfyUI环境共享一份models
把ComfyUI目录下的extra_model_paths.yaml.example文件重命名为extra_model_paths.yaml
然后把需要共享的models文件夹移动到
D:\AI\ComfyUI_models\
extra_model_paths.yaml文件的内容改成如下格式即可
#Rename this to extra_model_paths.yaml and ComfyUI will load it
#config for a1111 ui
#all you have to do is change the base_path to where yours is installed
# a111:
# base_path: path/to/stable-diffusion-webui/
# checkpoints: models/Stable-diffusion
# configs: models/Stable-diffusion
# vae: models/VAE
# loras: |
# models/Lora
# models/LyCORIS
# upscale_models: |
# models/ESRGAN
# models/RealESRGAN
# models/SwinIR
# embeddings: embeddings
# hypernetworks: models/hypernetworks
# controlnet: models/ControlNet
#config for comfyui
#your base path should be either an existing comfy install or a central folder where you store all of your models, loras, etc.
comfyui:
base_path: D:\AI\ComfyUI_models\
# You can use is_default to mark that these folders should be listed first, and used as the default dirs for eg downloads
#is_default: true
# checkpoints: checkpoints/
# clip: clip/
# clip_vision: clip_vision/
# configs: configs/
# controlnet: controlnet/
diffusion_models: |
diffusion_models
unet
# embeddings: embeddings/
# loras: loras/
# upscale_models: upscale_models/
# vae: vae/
adetailer: adetailer/
animatediff_models: animatediff_models/
animatediff_motion_lora: animatediff_motion_lora/
animatediff_video_formats: animatediff_video_formats/
blip: blip/
checkpoints: checkpoints/
clip: clip/
clip_vision: clip_vision/
configs: configs/
controlnet: controlnet/
deepbooru: deepbooru/
depthanything: depthanything/
diffusers: diffusers/
embeddings: embeddings/
ESRGAN: ESRGAN/
facerestore_models: facerestore_models/
florence2: florence2/
GFPGAN: GFPGAN/
gligen: gligen/
hypernetworks: hypernetworks/
insightface: insightface/
instantid: instantid/
ipadapter: ipadapter/
karlo: karlo/
llamafile: llamafile/
LLM: LLM/
loras: loras/
mmdets: mmdets/
onnx: onnx/
opencv: opencv/
photomaker: photomaker/
reactor: reactor/
RealESRGAN: RealESRGAN/
sams: sams/
ScuNET: ScuNET/
style_models: style_models/
SwinIR: SwinIR/
text_encoders: text_encoders/
ultralytics: ultralytics/
unet: unet/
upscale_models: upscale_models/
vae: vae/
vae_approx: vae_approx/
workflows: workflows/
xlabs: xlabs/
#other_ui:
# base_path: path/to/ui
# checkpoints: models/checkpoints
# gligen: models/gligen
# custom_nodes: path/custom_nodes
注意:如果你使用了xlabs这种组件(他会在models创建多级子目录,导致xlabs: xlabs/这种配置是找不到下级目录里的模型),就算你在extra_model_paths.yaml中配置出子目录也读取不到,只能改xlabs中读取模型的代码。