Mac 上安装 ComfyUI 使用 Flux

安装 ComfyUI

ComfyUI 文档

使用 Conda 创建一个环境

1
2
conda create -n comfyenv
conda activate comfyenv

克隆代码仓库

1
2
# 如果没有安装 git,会提示安装,点击安装,会自动安装
git clone https://github.com/comfyanonymous/ComfyUI.git

安装 PyTorch

/images/posts/Mac上安装ComfyUI使用Flux/1.png
(图1)
1
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

安装 ComfyUI 依赖

1
2
3
4
5
6
cd ComfyUI

# 若提示 command not found: pip (可选)
conda install pip

pip install -r requirements.txt
报错

Building wheels for collected packages: sentencepiece

这是在尝试安装 sentencepiece 包时,构建失败。这个包通常用于大语言模型(如 LLaMA)中的分词器,但在某些系统(尤其是 macOS)上编译它会比较麻烦。

使用 Conda 安装预编译版本

1
conda install -c conda-forge sentencepiece

启动 ComfyUI

1
2
cd ComfyUI
python main.py --listen 0.0.0.0

下载 Flux

ComfyUI 基础入门教程

本次安装的是 Flux.1 Dev GGUF 模型

/images/posts/Mac上安装ComfyUI使用Flux/2.png
(图2)
/images/posts/Mac上安装ComfyUI使用Flux/3.png
(图3)

第一步

Download the Flux GGUF dev model or the Flux GGUF schnell model and place the model files in the comfyui/models/unet directory.

安装 Flux GGUF dev model

/images/posts/Mac上安装ComfyUI使用Flux/4.png
(图4)

第二步

Download t5-v1_1-xxl-encoder-gguf, and place the model files in the comfyui/models/clip directory.

/images/posts/Mac上安装ComfyUI使用Flux/5.png
(图5)

第三步

Download clip_l.safetensors and place the model files in the comfyui/models/clip directory.

/images/posts/Mac上安装ComfyUI使用Flux/6.png
(图6)

第四步

Download ae.safetensors and place the model files in the comfyui/models/vae directory, and rename it to flux_ae.safetensors.

/images/posts/Mac上安装ComfyUI使用Flux/7.png
(图7)

第五步

Install ComfyUI-GGUF plugin, if you don’t know how to install the plugin, you can refer to ComfyUI Plugin Installation Guide

插件地址:ComfyUI-GGUF

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 进入到 ComfyUI 的 custom_nodes 目录下
cd ComfyUI/custom_nodes

# 拉取项目
git clone https://github.com/city96/ComfyUI-GGUF

# 进入到刚才拉取的项目中
cd ComfyUI-GGUF

# 安装依赖
pip install -r requirements.txt

使用

访问 http://127.0.0.1:8818 进入到 ComfyUI 页面

下载示例工作流

/images/posts/Mac上安装ComfyUI使用Flux/8.png
(图8)

将下载的文件拖入到 ComfyUI 页面

/images/posts/Mac上安装ComfyUI使用Flux/9.png
(图9)
/images/posts/Mac上安装ComfyUI使用Flux/10.png
(图10)

lora

/images/posts/Mac上安装ComfyUI使用Flux/11.png
(图11)

可以在网站上找到自己喜欢的模型,下载下来放入到 ComfyUI/models/loras 目录下,可以把他理解为是一个皮肤,后续生成的图片都是这种风格的

添加 loras 节点

/images/posts/Mac上安装ComfyUI使用Flux/12.png
(图12)
/images/posts/Mac上安装ComfyUI使用Flux/13.png
(图13)

0%