Skip to content

Latest commit

 

History

History
900 lines (662 loc) · 39 KB

comfyui_installer.md

File metadata and controls

900 lines (662 loc) · 39 KB

ComfyUI Installer

✨一键安装 ComfyUI

目录


简介

一个在 Windows 系统上部署 ComfyUI 的 PowerShell 脚本,并提供不同的管理工具。


环境配置

如果是初次使用 PowerShell 脚本,需要解除 Windows 系统对脚本的限制。

Windows 系统默认未启用长路径支持,这可能会导致部分功能出现异常,需要启用 Windows 长路径支持来解决该问题。

下面提供 2 种方法进行环境配置。

1. 使用自动环境配置脚本

下载环境自动配置脚本,双击运行configure_env.bat后将会弹出管理员权限申请提示,选择授权管理员权限给环境配置脚本,这时将自动配置运行环境。

环境配置脚本下载
下载地址 1
下载地址 2
下载地址 3
下载地址 4
下载地址 5

Note

使用自动环境配置脚本的方法和手动使用命令配置的方法效果一致。

2. 手动使用命令配置

2.1 解除脚本限制

使用管理员权限打开 PowerShell,运行以下命令:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

Note

关于 PowerShell 执行策略的说明:关于执行策略 ### PowerShell | Microsoft Learn

2.2 启用 Windows 长路径支持

在刚刚的 PowerShell 中运行下面的命令:

New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force

Note

关于 Windows 长路径支持的说明:最大路径长度限制 ### Win32 apps | Microsoft Learn


安装

将 ComfyUI Installer 下载至本地,右键comfyui_installer.ps1脚本,在弹出的右键菜单中点击使用 PowerShell 运行,此时 ComfyUI Installer 将安装 ComfyUI 至本地。

ComfyUI Installer 下载地址
下载地址 1
下载地址 2
下载地址 3
下载地址 4
下载地址 5

在 ComfyUI Installer 成功安装 ComfyUI 后,在ComfyUI文件夹中可以看到 ComfyUI 的文件和各种管理脚本。如果出现某个步骤运行失败,可尝试重新运行 ComfyUI Installer。

查看 ComfyUI Installer 为 ComfyUI 预装的扩展
ComfyUI 扩展
ltdrdata/ComfyUI-Manager
Fannovel16/comfyui_controlnet_aux
Kosinkadink/ComfyUI-Advanced-ControlNet
cubiq/ComfyUI_IPAdapter_plus
kijai/ComfyUI-Marigold
pythongosssss/ComfyUI-WD14-Tagger
BlenderNeko/ComfyUI_TiledKSampler
pythongosssss/ComfyUI-Custom-Scripts
LEv145/images-grid-comfy-plugin
ssitu/ComfyUI_UltimateSDUpscale
AlekPet/ComfyUI_Custom_Nodes_AlekPet
talesofai/comfyui-browser
ltdrdata/ComfyUI-Inspire-Pack
Suzie1/ComfyUI_Comfyroll_CustomNodes
crystian/ComfyUI-Crystools
shiimizu/ComfyUI-TiledDiffusion
huchenlei/ComfyUI-openpose-editor
licyk/ComfyUI-Restart-Sampler
weilin9999/WeiLin-ComfyUI-prompt-all-in-one

Note

  1. 如果运行 PowerShell 脚本出现闪退,说明 Windows 对 PowerShell 脚本的运行限制未解除,需要按照环境配置中的方法进行解除。
  2. ComfyUI Installer 支持使用在命令行中通过参数配置 ComfyUI 的安装参数,具体说明可阅读使用命令运行 ComfyUI Installer

使用

ComfyUI文件夹中可以看到不同的 PowerShell 脚本,右键 PowerShell 脚本,选择使用 PowerShell 运行后即可运行。在ComfyUI文件夹中也有 PowerShell 脚本,但不建议使用该文件夹中的脚本进行运行。

启动 ComfyUI

运行launch.ps1脚本。

更新 ComfyUI

运行update.ps1脚本,如果遇到更新 ComfyUI 失败的情况可尝试重新运行update.ps1脚本。

更新 ComfyUI 自定义节点

运行update_node.ps1脚本,如果遇到更新 ComfyUI 自定义节点失败的情况可尝试重新运行update_node.ps1脚本。

设置 ComfyUI 启动参数

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

要设置 ComfyUI 的启动参数,可以在和launch.ps1脚本同级的目录创建一个launch_args.txt文件,在文件内写上启动参数,运行 ComfyUI 启动脚本时将自动读取该文件内的启动参数并应用。

进入 ComfyUI 所在的 Python 环境

如果需要使用 Python、Pip、ComfyUI 的命令时,请勿将 ComfyUI 的python文件夹添加到环境变量,这将会导致不良的后果产生。

正确的方法是在 ComfyUI 目录中打开 PowerShell,在 PowerShell 中运行下面的命令进入 ComfyUI Env:

.\activate.ps1

这样就进入 ComfyUI 所在的 Python 环境,可以在这个环境中使用该环境的 Python 等命令。

或者运行terminal.ps1脚本,这将打开 PowerShell 并自动执行activate.ps1,此时就进入了 ComfyUI 所在的 Python。

获取最新的 ComfyUI Installer 并运行

运行launch_comfyui_installer.ps1脚本,如果下载成功将会把 ComfyUI Installer 下载到cache目录中并运行。

恢复被修改 / 删除的脚本

如果不小心把某个脚本修改了导致无法使用,或者是误删除了,可以运行一次launch_comfyui_installer.ps1重新生成这些脚本。

$ tree -L 2
.
├── BaiduNetworkDownloads
│   └── 新建 文本文档.txt
├── ComfyUI                           # 这是 ComfyUI 文件夹
│   ├── activate.ps1                  # 进入 ComfyUI Env 的脚本
│   ├── cache                         # 缓存文件夹
│   ├── download_models.ps1           # 下载模型的脚本
│   ├── launch_comfyui_installer.ps1  # 获取最新的 ComfyUI Installer 并运行的脚本
│   ├── git                           # Git 目录
│   ├── help.txt                      # 帮助文档
│   ├── launch.ps1                    # 启动 ComfyUI 的脚本
│   ├── ComfyUI                       # ComfyUI 路径
│   ├── python                        # Python 目录
│   ├── reinstall_pytorch.ps1         # 重新安装 PyTorch 的脚本
│   ├── settings.ps1                  # 管理 ComfyUI Installer 设置的脚本
│   ├── terminal.ps1                  # 自动打开 PowerShell 并激活 ComfyUI Installer 的虚拟环境脚本
│   ├── update_node.ps1               # 更新 ComfyUI 自定义节点
│   └── update.ps1                    # 更新 ComfyUI 的脚本
├── comfyui_installer.ps1             # ComfyUI Installer 一般放在 ComfyUI 文件夹外面,和 ComfyUI 文件夹同级
└── QQ Files

8 directories, 9 files

设置 HuggingFace 镜像

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

ComfyUI Installer 生成的 PowerShell 脚本中已设置了 HuggingFace 镜像源,如果需要自定义 HuggingFace 镜像源,可以在和脚本同级的目录创建hf_mirror.txt文件,在文件中填写 HuggingFace 镜像源的地址后保存,再次启动脚本时将读取该文件的配置并设置 HuggingFace 镜像源。

可用的 HuggingFace 镜像源
https://hf-mirror.com
https://huggingface.sukaka.top

如果需要禁用设置 HuggingFace 镜像源,在和脚本同级的目录中创建disable_hf_mirror.txt文件,再次启动脚本时将禁用 HuggingFace 镜像源。

设置 Github 镜像源

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

ComfyUI Installer 为了加速访问 Github 的速度,加快下载和更新 ComfyUI 的速度,默认在启动脚本时自动检测可用的 Github 镜像源并设置。如果需要自定义 Github 镜像源,可以在和脚本同级的目录创建gh_mirror.txt文件,在文件中填写 Github 镜像源的地址后保存,再次启动脚本时将取消自动检测可用的 Github 镜像源,而是读取该文件的配置并设置 Github 镜像源。

可用的 Github 镜像源
https://ghfast.top/https://github.com
https://mirror.ghproxy.com/https://github.com
https://ghproxy.net/https://github.com
https://gh.api.99988866.xyz/https://github.com
https://gitclone.com/github.com
https://gh-proxy.com/https://github.com
https://ghps.cc/https://github.com
https://gh.idayer.com/https://github.com

如果需要禁用设置 Github 镜像源,在和脚本同级的目录中创建disable_gh_mirror.txt文件,再次启动脚本时将禁用 Github 镜像源。

设置 Pip 镜像源

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

ComfyUI Installer 默认启用了 Pip 镜像源加速下载 Python 软件包,如果需要禁用 Pip 镜像源,可以在脚本同级目录创建disable_pip_mirror.txt文件,再次运行脚本时将 Pip 源切换至官方源。

配置代理

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

如果出现某些文件无法下载,比如在控制台出现由于连接芳在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败之类的报错时,可以尝试配置代理,有以下 2 种方法。

1. 使用系统代理

在代理软件中启用系统代理,再运行脚本,这时候脚本将自动读取系统中的代理配置并设置代理。

2. 使用配置文件

在和脚本同级的路径中创建一个proxy.txt文件,在文件中填写代理地址,如http://127.0.0.1:10809,保存后运行脚本,这时候脚本会自动读取这个配置文件中的代理配置并设置代理。

Note

配置文件的优先级高于系统代理配置,所以当同时使用了两种方式配置代理,脚本将优先使用配置文件中的代理配置。

禁用自动设置代理

在和脚本同级的路径中创建一个disable_proxy.txt文件,再次启动脚本时将禁用设置代理。

共享 Stable Diffusion WebUI 的模型

在 ComfyUI 启动一次后,在 ComfyUI 的根目录会生成一个 extra_model_paths.yaml.example 共享目录示例文件,通过修改这个文件可以使 ComfyUI 共享 Stable Diffusion WebUI 的模型文件。

这是一个例子,我的 Stable Diffusion WebUI 路径在E:/Softwares/stable-diffusion-webui,则将这个示例文件的base_path:后面的路径改成 Stable Diffusion WebUI 的路径。

#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: E:/Softwares/stable-diffusion-webui # 填写 Stable Diffusion WebUI 的路径, 注意冒号后面必须有空格

    checkpoints: models/Stable-diffusion # 大模型
    configs: models/Stable-diffusion # 大模型配置文件
    vae: models/VAE # VAE 模型
    loras: | # LoRA 模型
         models/Lora
         models/LyCORIS
    upscale_models: | # 放大模型
                  models/ESRGAN
                  models/RealESRGAN
                  models/SwinIR
    embeddings: embeddings # Embedding 模型
    hypernetworks: models/hypernetworks # Hypernetwork 模型
    controlnet: models/Controlnet # ControlNet 模型
    ipadapter: models/Controlnet # IP Adapter 模型
    clip_vision: extensions/sd-webui-controlnet/annotator/downloads/clip_vision # clip_vision 模型
    # AnimateDiff 模型共享的说明: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved?tab=readme-ov-file#model-setup
    animatediff_models: extensions/sd-webui-animatediff/model # AnimateDiff 模型
    animatediff_motion_lora: extensions/sd-webui-animatediff/model # AnimateDiff LoRA 模型


#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: path/to/comfyui/
#     checkpoints: models/checkpoints/
#     clip: models/clip/
#     configs: models/configs/
#     controlnet: models/controlnet/
#     embeddings: models/embeddings/
#     loras: models/loras/
#     upscale_models: models/upscale_models/
#     vae: models/vae/
#     classifiers: models/classifiers/
#     clip_vision: models/clip_vision/
#     diffusers: models/diffusers/
#     diffusion_models: models/diffusion_models/
#     gligen: models/gligen/
#     hypernetworks: models/hypernetworks/
#     photomaker: models/photomaker/
#     style_models: models/style_models/
#     unet: models/unet/
#     vae_approx: models/vae_approx/
#     animatediff_models: models/animatediff_models/
#     animatediff_motion_lora: models/animatediff_motion_lora/
#     animatediff_video_formats: models/animatediff_video_formats/
#     ipadapter: models/ipadapter/
#     liveportrait: models/liveportrait/
#     insightface: models/insightface/
#     layerstyle: models/layerstyle/
#     LLM: models/LLM/
#     Joy_caption: models/Joy_caption/
#     sams: models/sams/
#     blip: models/blip/
#     CogVideo: models/CogVideo/
#     xlabs: models/xlabs/
#     instantid: models/instantid/
#     custom_nodes: custom_nodes/


#other_ui:
#    base_path: path/to/ui
#    checkpoints: models/checkpoints
#    gligen: models/gligen
#    custom_nodes: path/custom_nodes

下载模型

可以使用download_models.ps1脚本下载模型。这里也推荐使用 HuggingFace 或者 Civitai 下载模型。

ComfyUI 使用方法

推荐的哔哩哔哩 UP 主:

ComfyUI 的使用教程:

使用绘世启动器

Note

如果使用自动的方法,可以参考命令的使用中的安装绘世启动器并自动配置绘世启动器所需的环境命令,该命令可一键配置下载绘世启动器并配置,或者可以尝试下面手动配置绘世启动器的方法。

ComfyUI Installer 部署出来的 ComfyUI 可以通过绘世启动器进行启动,使用绘世启动器前需要调整目录结构使绘世启动器能够正确识别到环境。

ComfyUI/python目录移动到ComfyUI/ComfyUI/pythonComfyUI/git移动到ComfyUI/ComfyUI/git

移动前目录的结构如下。

.
├── ComfyUI
│   ├── activate.ps1
│   ├── cache
│   ├── download_models.ps1
│   ├── launch_comfyui_installer.ps1
│   ├── git                           # Git 目录
│   ├── help.txt
│   ├── launch.ps1
│   ├── ComfyUI                       # ComfyUI 路径
│   │   ├── ...
│   │   └── main.py
│   ├── python                        # Python 目录
│   ├── reinstall_pytorch.ps1
│   ├── settings.ps1
│   ├── terminal.ps1
│   ├── update_node.ps1
│   └── update.ps1
└── comfyui_installer.ps1          

移动 Python 和 Git 之后的目录结构。

.
├── ComfyUI
│   ├── activate.ps1
│   ├── cache
│   ├── download_models.ps1
│   ├── launch_comfyui_installer.ps1
│   ├── help.txt
│   ├── launch.ps1
│   ├── ComfyUI                       # ComfyUI 路径
│   │   ├── git                       # Git 目录
│   │   ├── python                    # Python 目录
│   │   ├── ...
│   │   └── main.py
│   ├── reinstall_pytorch.ps1
│   ├── settings.ps1
│   ├── terminal.ps1
│   ├── update_node.ps1
│   └── update.ps1
└── comfyui_installer.ps1          

再下载绘世启动器放到ComfyUI/ComfyUI目录中,就可以通过启动器启动 ComfyUI。

绘世启动器下载
下载地址 1
下载地址 2
下载地址 3

重装 ComfyUI

ComfyUI文件夹中的ComfyUI文件夹删除,然后运行launch_comfyui_installer.ps1重新部署 ComfyUI。

Note

如果ComfyUI文件夹存放了模型文件,请将这些文件备份后再删除ComfyUI文件夹。

重装 Python 环境

如果 Python 环境出现严重损坏,可以将ComfyUI/pythonComfyUI/ComfyUI/python文件夹删除,然后运行launch_comfyui_installer.ps1重新构建 Python 环境。

重装 Git

ComfyUI/gitComfyUI/ComfyUI/git文件夹删除,然后运行launch_comfyui_installer.ps1重新下载 Git。

重装 PyTorch

运行reinstall_pytorch.ps1脚本,并根据脚本提示的内容进行操作。

卸载 ComfyUI

使用 ComfyUI Installer 安装 ComfyUI 后,所有的文件都存放在ComfyUI文件夹中,只需要删除ComfyUI文件夹即可卸载 ComfyUI。

如果有 ComfyUI 快捷启动方式,可以通过命令进行删除,打开 PowerShell 后,输入以下命令进行删除。

Remove-Item -Path "$([System.Environment]::GetFolderPath("Desktop"))\ComfyUI.lnk" -Force
Remove-Item -Path "$Env:APPDATA\Microsoft\Windows\Start Menu\Programs\ComfyUI.lnk" -Force

移动 ComfyUI 的路径

直接将ComfyUI文件夹移动到别的路径即可。

如果启用了自动创建 ComfyUI 快捷启动方式的功能,移动 ComfyUI 后原来的快捷启动方式将失效,需要运行launch.ps1更新快捷启动方式。

更新 ComfyUI 管理脚本

ComfyUI Installer 的管理脚本在启动时会检查管理脚本的更新,如果有新版本可更新将会提示。

可选择下方 4 种方法中的其中 1 个方法进行更新。

1. 直接更新

当检测到有新版的 ComfyUI Installer 时,将询问是否进行更新,输入y并回车后将运行 ComfyUI Installer 进行更新。

2. 使用 ComfyUI Installer 配置管理器进行更新

运行settings.ps1,选择更新 ComfyUI Installer 管理脚本功能进行更新,更新完成后需关闭 ComfyUI Installer 管理脚本以应用更新。

3. 运行 ComfyUI Installer 进行更新

运行launch_comfyui_installer.ps1获取最新的 ComfyUI Installer 后,脚本会自动运行新版 ComfyUI Installer 进行更新。

4. 使用命令更新

参考命令的使用的方法进入 ComfyUI Env,并运行Check-ComfyUI-Installer-Update命令进行更新。

禁用 ComfyUI Installer 更新检查

Warning

通常不建议禁用 ComfyUI Installer 的更新检查,当 ComfyUI 管理脚本有重要更新(如功能性修复)时将得不到及时提示。

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

如果要禁用更新检查,可以在脚本同级的目录创建disable_update.txt文件,这将禁用 ComfyUI Installer 更新检查。

设置 uv 包管理器

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

ComfyUI Installer 默认使用了 uv 作为 Python 包管理器,大大加快管理 Python 软件包的速度(如安装 Python 软件包)。

如需禁用 uv,可在脚本所在目录创建一个disable_uv.txt文件,这将禁用 uv,并使用 Pip 作为 Python 包管理器。

Note

  1. 当 uv 安装 Python 软件包失败时,将切换至 Pip 重试 Python 软件包的安装。
  2. uv 包管理器对网络的稳定性要求更高,在网络不稳定时可能会出现下载软件包出错的问题,可尝试重新运行,或者禁用 uv,这时将切换成 Pip 作为 Python 包管理器,Pip 在网络稳定性差的情况下不容易出错,但这将降低 Python 软件包的安装速度。

创建快捷启动方式

Note

该设置可通过管理 ComfyUI Installer 设置中提到的的settings.ps1进行修改。

在脚本同级目录创建enable_shortcut.txt文件,当运行launch.ps1时将会自动创建快捷启动方式,并添加到 Windows 桌面和 Windows 开始菜单中,下次启动时可以使用快捷方式启动 ComfyUI。

Important

如果 ComfyUI 的路径发生移动,需要重新运行launch.ps1更新快捷启动方式。

管理 ComfyUI Installer 设置

运行settings.ps1,根据提示进行设置管理和调整。

ComfyUI Installer 对 Python / Git 环境的识别

ComfyUI Installer 通常情况下不会去调用系统环境中的 Python / Git,所以在安装过程会安装一个独立的 Python / Git 避免收到系统环境中的 Python / Git 影响。

ComfyUI Installer 可以识别到的 Python 路径为ComfyUI/pythonComfyUI/ComfyUI/python,当两者同时存在时,优先使用后者。

可以识别到的 Git 路径为ComfyUI/gitComfyUI/ComfyUI/git,当两者同时存在时,优先使用后者。

如果这两个路径 Python / Git 都不存在时,此时 ComfyUI 的管理脚本将会调用系统环境中的 Python / Git,这可能会带来不好的结果,所以出现这种情况时就需要运行 ComfyUI Installer 重新安装 Python / Git。

使用命令运行 ComfyUI Installer

ComfyUI Installer 支持使用命令参数设置安装 ComfyUI 的参数,支持的参数如下。

参数 作用
-InstallPath <ComfyUI 安装路径> 指定安装 ComfyUI 的路径,使用绝对路径进行指定。
-UseUpdateMode 使用 ComfyUI Installer 的更新脚本模式,不进行 ComfyUI 的安装。
-DisablePipMirror 禁用 ComfyUI Installer 使用 Pip 镜像源, 使用 Pip 官方源下载 Python 软件包。
-DisableProxy 禁用 ComfyUI Installer 自动设置代理服务器。
·UseCustomProxy <代理服务器地址> 使用自定义的代理服务器地址。
-DisableUV 禁用 ComfyUI Installer 使用 uv 安装 Python 软件包, 使用 Pip 安装 Python 软件包。
-DisableGithubMirror 禁用 ComfyUI Installer 自动设置 Github 镜像源。
-UseCustomGithubMirror <Github 镜像站地址> 使用自定义的 Github 镜像站地址。
可用的 Github 镜像站地址:
https://ghfast.top/https://github.com
https://mirror.ghproxy.com/https://github.com
https://ghproxy.net/https://github.com
https://gh.api.99988866.xyz/https://github.com
https://gitclone.com/github.com
https://gh-proxy.com/https://github.com
https://ghps.cc/https://github.com
https://gh.idayer.com/https://github.com
-Help 显示 ComfyUI Installer 可用的命令行参数。

例如在D:/Download这个路径安装 ComfyUI,则在 ComfyUI Installer 所在路径打开 PowerShell,使用参数运行 ComfyUI Installer。

.\comfyui_installer.ps1 -InstallPath "D:/Download"

运行脚本时出现中文乱码

这可能是 Windows 系统中启用了 UTF 8 编码,可以按照下列方法解决。

  1. 按下Win + R键,输入control后回车启动控制面板。
  2. 点击时钟和区域->区域
  3. 在弹出的区域设置窗口中点击顶部的管理,再点击更改系统区域设置.
  4. 在弹出的窗口中将使用 Unicode UTF-8 提供全球语言支持取消勾选,然后一直点击确定保存设置,并重启电脑。

无法使用 PowerShell 运行

运行 PowerShell 脚本时出现以下错误。

.\comfyui_installer.ps1 : 无法加载文件 D:\ComfyUI\comfyui_installer.ps1。
未对文件 D:\ComfyUI\comfyui_installer.ps1进行数字签名。无法在当前系统上运行该脚本。
有关运行脚本和设置执行策略的详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ .\comfyui_installer.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : SecurityError: (:) [],PSSecurityException
   + FullyQualifiedErrorId : UnauthorizedAccess

或者右键运行 PowerShell 脚本时闪一下 PowerShell 的界面后就消失了。

这是因为未解除 Windows 系统对运行 PowerShell 脚本的限制,请使用管理员权限打开 PowerShell,运行下面的命令。

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

或者使用自动环境配置脚本解除 Windows 系统对运行 PowerShell 脚本的限制。

PowerShell 中出现 xFormers 报错

在控制台中出现有关 xFormers 的警告信息,类似下面的内容。

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.2.1+cu118 with CUDA 1108 (you have 2.2.2+cu121)
    Python  3.10.11 (you have 3.10.11)
  Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
  Memory-efficient attention, SwiGLU, sparse and more won't be available.

这是因为 xFormers 所适配的 CUDA 版本和 PyTorch 所带的 CUDA 版本不一致,请运行reinstall_pytorch.ps1重装 PyTorch。

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE

运行 ComfyUI Installer 时出现以下类似的错误。

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    rsa<5,>=3.1.4 from https://mirrors.cloud.tencent.com/pypi/packages/49/97/fa78e3d2f65c02c8e1268b9aba606569fe97f6c8f7c2d74394553347c145/rsa-4.9-py3-none-any.whl#sha256=90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7 (from google-auth<3,>=1.6.3->tensorboard==2.10.1->-r requirements.txt (line 12)):
        Expected sha256 90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7
             Got        b7593b59699588c6ce7347aecf17263295c079efb3677553c2a81b08e857f838

这是因为下载下来的 Python 软件包出现了损坏,Pip 无法进行安装,需要将ComfyUI/cache/pip文件夹删除,再重新运行 ComfyUI Installer。

CUDA out of memory

尝试使用分块编 / 解码 VAE 节点,降低出图分辨率。

DefaultCPUAllocator: not enough memory

尝试增加系统的虚拟内存,或者增加内存条。

以一种访问权限不允许的方式做了一个访问套接字的尝试

启动 ComfyUI 时出现以下的错误。

ERROR: [Error 13] error while attempting to bind on address ('127.0.0.1', 28000): 以一种访问权限不允许的方式做了一个访问套接字的尝试。

这是因为该端口被其他软件占用,ComfyUI 无法使用。可尝试将占用该端口的软件关闭,或者在launch.ps1所在目录创建launch_args.txt文件,在该文件中写上启动参数把 ComfyUI 端口修改,如--port 8888,保存launch_args.txt文件后使用launch.ps1重新启动 ComfyUI。

Note

设置 ComfyUI 启动参数的方法可参考设置 ComfyUI 启动参数

Microsoft Visual C++ Redistributable is not installed, this may lead to the DLL load failure.

下载 Microsoft Visual C++ Redistributable 并安装。

命令的使用

使用命令前需要激活环境,有以下 2 种方式激活。

1. 使用自动环境激活脚本

运行terminal.ps1后将自动打开 PowerShell 并激活 ComfyUI Env。

2. 手动输入命令激活

ComfyUI文件夹打开 PowerShell,输入下面的命令激活 ComfyUI Env:

.\activate.ps1

Important

在 PowerShell 中一定要显示[ComfyUI Env]才算进入了环境,这样才能使用下面的命令。

常用命令

清理安装时产生的 Pip 缓存

python -m pip cache purge

安装某个 Pip 软件包

# 命令中的 <package_name> 替换成具体的 Python 软件包名 
python -m pip install <package_name>

更新某个软件包

# 命令中的 <package_name> 替换成具体的 Python 软件包名
python -m pip install <package_name> -U

重装某个软件包

# 命令中的 <package_name> 替换成具体的 Python 软件包名
python -m pip install <package_name> --force-reinstall

卸载某个软件包

# 命令中的 <package_name> 替换成具体的 Python 软件包名
python -m pip uninstall <package_name>

Note

推荐使用python -m pip的写法,pip的写法也可用。ComfyUI Installer 默认将pip命令链接到python -m pip避免直接调用pip
参考:Deprecate pip, pipX, and pipX.Y · Issue #3164 · pypa/pip

使用 uv 安装软件包

# 命令中的 <package_name> 替换成具体的 Python 软件包名
uv pip install <package_name>

Note

uv 命令的用法可参考:uv docs

更新仓库

git pull --recurse-submodules

运行某个 Python 脚本

# 命令中的 <python_script.py> 替换成要执行的 Python 脚本路径
python <python_script.py>

下载文件

# 命令中的 <url> 替换成下载链接,<dir> 替换成下载到的路径,<output_file_name> 替换成保存的文件名
aria2c <url> -c -s 16 -x 16 -k 1M -d <dir> -o <output_file_name>

更新 uv

Update-uv

更新 Aria2

Update-Aria2

测试可用的 Github 镜像源并应用

Test-Github-Mirror

安装 ComfyUI 自定义节点

# <url> 为 ComfyUI 自定义节点的下载链接
Install-ComfyUI-Node <url>

Git 下载命令

# <url> 为下载链接, <path> 为下载到的路径
Git-Clone <url> <path>

安装绘世启动器并自动配置绘世启动器所需的环境

Install-Hanamizuki

Important

运行该命令前请确保 ComfyUI 已经关闭。

列出 ComfyUI 已存在的自定义节点

List-Node

列出 ComfyUI Installer 内置命令

List-CMD

检查 ComfyUI Installer 更新

Check-ComfyUI-Installer-Update

查看并切换 ComfyUI 的版本

# 列出当前的所有版本
git -C ComfyUI tag
# 运行该命令后将进入 Git 的交互式界面
# 使用 u 键上翻, d 键下翻,或者使用方向键翻页,使用 q 键退出
# 一般 git tag 命令将列出下面类似的输出
# v0.1.0
# v0.2.0
# v1.1.0
# v1.4.0
# v1.6.0
# v1.7.0
# v1.7.3
# ...
# 这是使用 Git Tag 标记的版本,可以使用 Tag 作为版本号进行切换

# 使用 Tag 切换版本
# 命令中的 <Git Tag> 替换成对应的 Tag
git -C ComfyUI reset --hard --recurse-submodules <Git Tag>

# 使用 git log 查看某个提交信息对应的 Hash 值
git -C ComfyUI log
# 这将得到类似的输出信息
# commit 9aace3e94c2c41a44e3df403329abd0518467bf5 (HEAD -> main, tag: v1.9.0)
# Author: Akegarasu <akiba@anzu.link>
# Date:   Sat Aug 31 22:32:52 2024 +0800
#
#     add vae_batch_size
#
# commit 931392e3c90aab20473175c9196d70fcfe039491
# Author: Akegarasu <akiba@anzu.link>
# Date:   Sat Aug 31 22:31:04 2024 +0800
#
#     tagger
#
# commit 后面对应的字符串为该提交信息对应的 Hash 值

# 可以使用该 Hash 切换版本
# 命令中的 <Git Commit Hash> 替换成对应的 Hash 值
git -C ComfyUI reset --hard --recurse-submodules <Git Commit Hash>

查看 Git / Python 命令实际调用的路径

# 查看 Git 命令调用的路径
(Get-Command git).Source

# 查看 Python 命令调用的路径
(Get-Command python).Source

# 查看其他命令的实际调用路径也是同样的方法
# (Get-Command <command>).Source