m4 mac mini本地部署ComfyUI,测试Flux-dev-GGUF的workflow模型10步出图,测试AI绘图性能,基于MPS(fp16),优点是能耗小和静音

在这里插入图片描述

m4 mac mini已经发布了一段时间,针对这个产品,更多的是关于性价比的讨论,如果抛开各种补贴不论,价位上和以前发布的mini其实差别不大,真要论性价比,各种windows系统的mini主机的价格其实是吊打苹果的。

本次我们针对m4 mac mini的AI性能做个测试,使用目前泛用性最广的AI工作流软件:ComfyUI框架,基于MPS(fp16)模式进行测试。

Mac Os 本地部署ComfyUI

首先确保本机已经安装好了基于arm架构的Python3.11,之所以使用Python3.11,是因为这个版本性能有一定的优化,又不会像最新的3.13由于版本过新,引发依赖装不上的问题。

Mac版本Python3.11安装包的下载地址:

https://python.org

随后克隆官方项目:

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

接着安装 MPS 版本的 torch

pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

然后安装依赖:

pip3 install -r requirements.txt

依赖安装完毕后,需要升级一下SSL证书:

bash /Applications/Python*/Install\ Certificates.command

接着安装 ComfyUI 的 Manager 项目,用来安装各种节点:

cd custom_nodes  
git clone https://github.com/ltdrdata/ComfyUI-Manager.git

至此ComfyUI项目就部署好了。

Flux-dev-GGUF模型下载

下载需要的flux-dev模型,由于官方的模型体积太大(23G),这里我们下载GGUF的量化版本:

https://pan.quark.cn/s/2907b57697fe

模型名称分别是:flux1-dev-Q4_1.gguf和t5-v1_1-xxl-encoder-Q5_K_M.gguf,将其分别放到models的UNET目录和clip目录。

随后,回到项目的根目录,输入命令,启动ComfyUI服务:

python3 main.py --force-fp16

这里强制使用fp16精度用来提升性能。

程序返回:

liuyue@mini ComfyUI % python3 main.py --force-fp16  
[START] Security scan  
[DONE] Security scan  
## ComfyUI-Manager: installing dependencies done.  
** ComfyUI startup time: 2024-12-08 23:04:08.464703  
** Platform: Darwin  
** Python version: 3.11.9 (v3.11.9:de54cf5be3, Apr  2 2024, 07:12:50) [Clang 13.0.0 (clang-1300.0.29.30)]  
** Python executable: /Library/Frameworks/Python.framework/Versions/3.11/bin/python3  
** ComfyUI Path: /Volumes/ssd/work/ComfyUI  
** Log path: /Volumes/ssd/work/ComfyUI/comfyui.log  
  
Prestartup times for custom nodes:  
   0.7 seconds: /Volumes/ssd/work/ComfyUI/custom_nodes/ComfyUI-Manager  
  
Total VRAM 24576 MB, total RAM 24576 MB  
pytorch version: 2.5.1  
Forcing FP16.  
Set vram state to: SHARED  
Device: mps  
Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --use-split-cross-attention  
[Prompt Server] web root: /Volumes/ssd/work/ComfyUI/web  
### Loading: ComfyUI-Manager (V2.51.9)  
### ComfyUI Revision: 2859 [b4526d3f] | Released on '2024-11-24'  
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json  
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json  
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json  
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json  
Torch version 2.5.1 has not been tested with coremltools. You may run into unexpected errors. Torch 2.4.0 is the most recent version that has been tested.  
[ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json  
  
Import times for custom nodes:  
   0.0 seconds: /Volumes/ssd/work/ComfyUI/custom_nodes/websocket_image_save.py  
   0.0 seconds: /Volumes/ssd/work/ComfyUI/custom_nodes/ComfyUI-GGUF  
   0.1 seconds: /Volumes/ssd/work/ComfyUI/custom_nodes/ComfyUI-Manager  
   2.2 seconds: /Volumes/ssd/work/ComfyUI/custom_nodes/ComfyUI-MLX  
  
Starting server  
  
To see the GUI go to: http://127.0.0.1:8188

代表部署成功,访问:http://127.0.0.1:8188

测试Flux-dev-GGUF工作流

下载基于GGUF的工作流:

https://promptingpixels.com/flux-gguf/

导入工作流后,输入提示词:

a super sexy gal holding a sign that says "ComfyUI Mac"

意思是性感女子举着一个牌子,上面写着 ComfyUI Mac

此时,可以直接执行工作流,程序返回:

ggml_sd_loader:  
 13                            144  
 0                              50  
 14                             25  
Requested to load FluxClipModel_  
Loading 1 new model  
loaded completely 0.0 323.94775390625 True  
Requested to load FluxClipModel_  
Loading 1 new model  
  
ggml_sd_loader:  
 1                             476  
 3                             304  
model weight dtype torch.bfloat16, manual cast: None  
model_type FLUX  
Requested to load Flux  
Loading 1 new model  
loaded completely 0.0 7181.8848876953125 True  
 20%|██████████████████▌                                                                          | 2/10 [01:04<04:18, 32.27s/it]

每秒的迭代稳定在30次左右,一张图大概需要3-5分钟左右。

笔者的 m4 mac mini 的配置是丐版升级到24G内存,在出图的过程中,通过活动监视器可知,内存没有被占满:

可以看到,只使用了21G的内存,有网友使用纯丐版16G内存的mini进行测试,16g内存实际刨除系统占用,空闲最多也就10g,超出的部分只能跑SSD的虚拟内存,导致GPU跑不满,所以丐版16G内存是有可能导致出图的效率降低。

最后是10步迭代的出图效果:

可以看到,精度没有下降太多,主要问题还是出图速度太慢。

结语

m4 mac mini的AI生态还有很大的提升空间,建议AI从业者慎重购买,如果一定要买,也需要避开16G内存的版本,因为如果模型体积过大,16G内存中真正能使用的其实只有10G内存,有可能会导致模型推理效率降低,当然,我们也不能忽视m4 mac mini推理模型的优点,那就是能耗小相对省电,并且使用时的声音很小,不像N卡设备动不动就山呼海啸。

### 关于 FLUX1-dev-fp8 的技术文档及相关信息 FLUX1-dev-fp8 是一款基于 FP8 浮点精度优化的深度学习模型,在特定应用场景下提供了显著的性能提升[^1]。该模型不仅继承了 FLUX 系列产品的优势特性,还针对开发者的需求进行了多项改进。 #### 社区资源与支持 对于寻求更多关于 FLUX1-dev-fp8 技术细节的支持技术交流机会而言,活跃的技术社区是一个宝贵的资源库。InstantX/FLUX.1-dev-Controlnet-Union Shakker-Labs 维护的相关 GitHub 仓库中包含了大量由用户贡献的内容以及官方发布的资料,涵盖了从基础入门到高级应用的各种教程案例分享[^3]。 #### 官方文档的重要性 考虑到不同版本间可能存在功能性差异及随时间推移而产生的操作流程变更,查阅最新版官方文档显得尤为重要。这不仅能确保使用者掌握最前沿的功能特性,还能有效规避因过时信息而导致的操作失误[^4]。 ```python import requests def fetch_latest_docs(model_name="FLUX1-dev-fp8"): url = f"https://docs.example.com/{model_name}/latest" response = requests.get(url) if response.status_code == 200: return response.text else: raise Exception(f"Failed to retrieve documentation for {model_name}") print(fetch_latest_docs()) ``` 此段 Python 代码展示了如何通过 API 获取指定型号(此处为 FLUX1-dev-fp8)最新的在线文档内容。请注意替换 `https://docs.example.com` 为你所关注的具体项目站点地址。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘悦的技术分享

承您打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值