Mac ARM 平台手动部署 ComfyUI 指南

1206 字
6 分钟
Mac ARM 平台手动部署 ComfyUI 指南

对于 Mac 用户主要推荐使用 ComfyUI Desktop 版本,你可以访问ComfyUI Desktop 版本安装教程来使用 ComfyUI,之所以选择手动安装 ComfyUI 是因为在 Mac ARM Silicon 平台的 BUG 较多而桌面版(稳定版)的更新较为缓慢,使用手动安装的方式(可以自由的切换版本)获得最及时的问题修复以及新的功能支持,同时能做到让 ComfyUI 静默的运行,是我认为较为舒服的方式。

1、创建虚拟环境#

Install Miniconda. 这将帮助您安装 ComfyUI 所需的正确版本的 Python 和其他库。使用 Conda 创建一个环境。

conda create -n comfyenv
conda activate comfyenv

2、克隆代码仓库#

你需要保证你的系统上已经安装了 Git, 首先你需要打开终端(命令行),然后克隆代码仓库。

打开终端应用程序

git clone git@github.com:comfyanonymous/ComfyUI.git

3、安装GPU 及 ComfyUI 依赖#

1、安装 GPU 依赖

Mac ARM Silicon 平台执行

Terminal window
conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly

2、安装 ComfyUI 依赖

Terminal window
cd ~/ComfyUI
pip install -r requirements.txt

3、安装插件管理器(ComfyUI-Manager)

cd ~/ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
cd ComfyUI-Manager && pip install -r requirements.txt

4、安装汉化插件(装上后还是可以选择使用英文界面,可在设置中进行切换)

cd ~/ComfyUI/custom_nodes
git clone https://github.com/AIGODLIKE/AIGODLIKE-COMFYUI-TRANSLATION.git

3、启动 ComfyUI

Terminal window
cd ~/ComfyUI
python main.py

4、添加外部模型路径(可选)#

如果想要共用 ComfyUI/models​ 模型,通过 extra_model_paths.yaml 配置文件来添加额外模型搜索路径。

可以在 ComfyUI 的根目录下找到 extra_model_paths.yaml.example 的示例文件

ComfyUI/extra_model_paths.yaml.example

复制并重命名为 extra_model_paths.yaml​ 来使用, 并保持在 ComfyUI 的根目录下, 路径应该是 ComfyUI/extra_model_paths.yaml

参考配置如下:

Terminal window
#Rename this to extra_model_paths.yaml and ComfyUI will load it
#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: /Users/gowah_yue/Documents/AIGC/ComfyUI/
# # 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
animatediff_models: models/animatediff_models
animatediff_motion_lora: models/animatediff_motion_lora
animatediff_video_formats: models/animatediff_video_formats
blip: models/blip
checkpoints: models/checkpoints
clip: models/clip
clip_vision: models/clip_vision
CogVideo: models/CogVideo
configs: models/configs
controlnet: models/controlnet
diffusers: models/diffusers
diffusion_models: models/diffusion_models
embeddings: models/embeddings
gligen: models/gligen
hypernetworks: models/hypernetworks
insightface: models/insightface
Joy_caption: models/Joy_caption
layerstyle: models/layerstyle
liveportrait: models/liveportrait
LLM: models/LLM
loras: models/loras
model_patches: models/model_patches
photomaker: models/photomaker
style_models: models/style_models
text_encoders: models/text_encoders
unet: models/unet
upscale_models: models/upscale_models
vae: models/vae
vae_approx: models/vae_approx
xlabs: models/xlabs
#config for a1111 ui
#all you have to do is uncomment this (remove the #) and 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
# For a full list of supported keys (style_models, vae_approx, hypernetworks, photomaker,
# model_patches, audio_encoders, classifiers, etc.) see folder_paths.py.
#other_ui:
# base_path: path/to/ui
# checkpoints: models/checkpoints
# gligen: models/gligen
# custom_nodes: path/custom_nodes

这里我将之前桌面端使用过程留存的 models​ 文件夹迁移至 /Users/gowah_yue/Documents/AIGC/ComfyUI/​ 并作为 base_path 目录,各个模型文件夹分别使用相对路径。

如果想要和桌面端共存的朋友,可以在 macOS ComfyUI 桌面端 ~/Library/Application Support/ComfyUI/extra_models_config.yaml 做出相应的修改。

4、为 ComfyUI 服务创建自启动脚本#

~/Library/LaunchAgents​ 路径下创建 local.startup.comfyui.plist 文件参考如下:

Terminal window
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.startup.comfyui</string>
<key>EnvironmentVariables</key>
<dict>
<key>PYTORCH_ENABLE_MPS_FALLBACK</key>
<string>1</string>
<key>PYTORCH_MPS_HIGH_WATERMARK_RATIO</key>
<string>1.0</string>
<key>PYTORCH_MPS_LOW_WATERMARK_RATIO</key>
<string>0.9</string>
</dict>
<key>WorkingDirectory</key>
<string>/Users/gowah_yue/ComfyUI</string>
<key>ProgramArguments</key>
<array>
<string>/opt/miniconda3/envs/comfyenv/bin/python3</string>
<string>main.py</string>
<string>--listen</string>
<string>0.0.0.0</string>
<string>--port</string>
<string>8188</string>
<string>--cache-classic</string>
<string>--use-split-cross-attention</string>
<string>--normalvram</string>
<string>--output-directory</string>
<string>/Users/gowah_yue/Documents/AIGC/ComfyUI/data/output</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>StandardOutPath</key>
<string>/tmp/local.startup.comfyui.stdout.log</string>
<key>StandardErrorPath</key>
<string>/tmp/local.startup.comfyui.stderr.log</string>
</dict>
</plist>

脚本介绍:#

1、WorkingDirectory​ 的值(即 /path/to/your/app​)必须是你存放 main.py​ 文件和该文件所需所有其他资源文件的实际目录的绝对路径。

2、使用 ProgramArguments​ 实现 Python 运行,需要在之前创建 ComfyUI 的虚拟环境下(也就是需要运行 conda activate comfyenv​ 激活虚拟环境后)运行 which python3​ 获取在该环境下 python3​ 命令的实际路径,并写入到脚本文件的 <string> 中。

3、脚本同时加入了优化 Pytorch 环境变量 PYTORCH_ENABLE_MPS_FALLBACK​ 和 PYTORCH_MPS_HIGH_WATERMARK_RATIO​ 确保 PyTorch 不支持的情况不会立即报错或崩溃,而是会自动将该操作转移到 CPU 上执行,同时确保 PyTorch 将 内存缓存 限制在总 GPU 可用内存的 80%

日常维护#

Terminal window
# 1. 卸载旧配置
launchctl unload ~/Library/LaunchAgents/local.startup.comfyui.plist
# 2. 重新加载新配置
launchctl load ~/Library/LaunchAgents/local.startup.comfyui.plist
# 3. 立即启动新服务
launchctl start local.startup.comfyui

5、如何更新 ComfyUI#

1、拉取最新代码

使用命令行进入 ComfyUI 的安装路径,然后拉取最新代码。

cd <安装路径>/ComfyUI
git pull

2、安装依赖

使用命令行进入 ComfyUI 的安装路径,然后安装依赖。

你需要确保当前的 Python 环境是 ComfyUI 的虚拟环境,否则依赖会安装到系统级 Python 环境,污染系统级 Python 环境。

pip install -r requirements.txt

6、进阶优化#

  1. 外置硬盘部署:(上述的开机脚本需要修改其中的路径)
    手动安装版本可将整个 ComfyUI 文件夹拷贝至外置 SSD,启动时指定路径:

    cd /Volumes/SSD/ComfyUI && source venv/bin/activate && python main.py
  2. 性能调优​:
    编辑 ~/.bash_profile 添加环境变量提升推理速度:

    export PYTORCH_ENABLE_MPS_FALLBACK=1
    export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.8

    应用环境变量

    Terminal window
    source ~/.bash_profile

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
Mac ARM 平台手动部署 ComfyUI 指南
https://blog.moewah.com/posts/mac-arm-comfyui-manual-installation-guide/
作者
MoeWah
发布于
2025-03-11
许可协议
CC BY-NC-SA 4.0
相关文章 智能推荐
1
DeepSeek-V4-Flash 看不了图片?用 pi-image-bridge 给它装一双眼睛
AI实验室 DeepSeek-V4-Flash-0731 任务通过率高、价格便宜,但模型没有视觉能力。装 pi 扩展 pi-image-bridge,配置视觉模型当副驾,截图报错、设计稿、表格都能看懂。安装一条命令,配置两个字段即可。
2
Claude 深度研究指南:斯坦福验证的多视角提问法(附 4 个提示词)
AI实验室 斯坦福 STORM 方法实操版——用多视角提问让 Claude 做出博士级研究。5 种专家视角、矛盾地图、综合简报、同行评审,4 个可复制提示词。
3
Goal 是目的地,Loop 是导航:AI 真正变聪明的核心秘密
AI实验室 一文讲透 AI Agent 的两大核心概念:Goal(目标)与 Loop(循环)。从基础定义到 8 种主流 Loop 类型详解,再到可直接复用的提示词模板,帮你从被动提问者升级为 AI 指挥官。
4
有了 tmux 还需要 herdr 吗?一个给 AI Agent 用的「终端管家」
AI实验室 herdr 是一个终端原生的 Agent 多路复用器,专为同时运行多个 AI Agent 的开发者设计。它解决了 Agent 管理混乱、会话丢失、远程协作等痛点,不替换终端、不依赖 Electron。本文从实际使用体验出发,带你了解它的核心功能和上手方法。
5
Claude Code 的 CLAUDE.md 怎么写?这 12 条规则,管住 AI Agent 的静默失败
AI实验室 12 条 CLAUDE.md 规则完整指南,涵盖代码生成和 Agent 模式两个阶段。每条规则附带英文原文、中文解释和真实翻车场景。文末提供完整模板可直接复制。
随机文章 随机推荐

评论区

Profile Image of the Author

关于作者

MoeWah

我是 MoeWah,喵斯基部落的作者。一个折腾自托管、群晖 NAS、虚拟化运维与 SEO/GEO 实践的独立博主,10 年以上的企业站运维与SEO优化经验,文章来自真实部署与踩坑记录。为自己记录,为同路人分享。
专题
分类
站点统计
文章
205
分类
9
标签
449
总字数
413,413
运行时长
0
最后活动
0 天前

目录