ComfyUI安装——不同安装方式的区别,如何配置多个ComfyUI并存

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中读取模型的代码。

<think>嗯,用户遇到了ONNX模型加载失败的问题,错误信息是“ONNXRuntimeError: NO_SUCHFILE Load model failed 文件不存在 fan2_68_landmark.onnx”。我需要仔细分析可能的原因,并提供解决方案。 首先,我应该考虑文件路径是否正确。用户可能提供的路径有误,或者文件名拼写错误。比如,大小写是否匹配,是否有多余的空格或特殊字符。例如,fan2_68_landmark.onnx这个文件名是否正确?用户可能在代码中写错了,或者实际文件名有所不同。这时候需要建议用户检查绝对路径,或者使用相对路径时确认当前工作目录是否正确。 接下来,文件是否存在也是一个关键点。即使用户认为路径正确,但文件可能被误删、移动,或者下载不完整。建议用户手动检查文件是否存在于指定路径,并且确认文件权限是否允许读取。如果是Linux系统,可能需要使用ls命令查看;Windows的话,资源管理器直接查看。 然后,运行环境的工作目录可能和用户预期的不一致。比如,脚本执行的目录可能不是模型文件所在的目录,导致相对路径失效。这时候建议用户打印当前工作目录,或者使用绝对路径来确保正确性。 另外,用户提到参考了引用[1]中关于模型路径配置的内容。可能用户尝试通过extra_model_paths.yaml来引用模型,但某些模型需要放在特定目录下。需要提醒用户确认该配置文件是否正确,路径是否指向实际存放模型的位置,特别是对于必须放在特定目录的模型,不能仅通过配置文件指引。 还有,代码中的路径处理是否有误?比如在Python中使用反斜杠而不是正斜杠,或者在字符串中转义字符处理不当。建议用户使用原始字符串或双反斜杠,或者使用os.path模块来处理路径,避免路径分隔符的问题。 此外,文件权限问题也可能导致加载失败,尤其是在Linux或macOS系统下。需要检查文件是否有读取权限,必要时使用chmod修改权限。 最后,模型文件是否完整?下载过程中可能中断,导致文件损坏。建议用户重新下载或验证文件的哈希值。 总结下来,可能的解决方案包括检查路径、确认文件存在、调整工作目录、正确配置extra_model_paths.yaml、处理路径字符串、检查权限以及验证文件完整性。需要逐步引导用户排查这些可能性,并给出具体的操作步骤,比如打印当前路径、使用绝对路径等。同时结合用户提供的引用,提示他们注意配置文件的正确使用。</think>针对ONNX模型加载失败问题(错误提示:$ONNXRuntimeError: NO\_SUCHFILE$),按以下步骤排查和解决: 1. **路径有效性验证** - 使用Python代码直接打印完整路径: ```python import os print(os.path.abspath("fan2_68_landmark.onnx")) ``` - 比较控制台输出路径与实际文件路径,注意检查: - 文件名大小写是否完全匹配(如$Landmark$与$landmark$) - 路径分隔符类型(推荐使用$os.path.join()$生成路径) 2. **工作目录修正** - 在代码起始处强制设置工作目录: ```python import os os.chdir("/绝对路径/模型目录") # 替换为实际路径 ``` 3. **模型路径配置(引用[1]相关)** - 当使用$extra\_model\_paths.yaml$时: ```yaml base_path: D:/Shared_Models/ onnx: base_path: "{{base_path}}/onnx_models/" ``` - 需确保配置语法符合YAML规范,且路径层级与实际存储结构完全对应[^1] 4. **运行环境检测** - 通过命令行工具验证文件可访问性: ```bash # Linux/macOS ls -l $(python -c "print(__import__('os').path.abspath('fan2_68_landmark.onnx'))") # Windows PowerShell Get-Item (python -c "print(__import__('os').path.abspath('fan2_68_landmark.onnx'))") ``` 5. **文件完整性校验** - 计算文件哈希值确认完整性: ```python import hashlib def file_hash(filename): with open(filename, "rb") as f: return hashlib.md5(f.read()).hexdigest() print(file_hash("fan2_68_landmark.onnx")) ``` - 比对官方提供的MD5校验值
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值