ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

[Feature Request] Please provide support for using MPS acceleration on Apple chips

Open NextDoorLaoHuang-HF opened this issue 2 years ago • 9 comments

I tried to load the comfy ui in the AUTOMATIC1111 webui venv environment, which uses MPS acceleration by default, but I failed. The comfy ui only ran in cpu mode on my m1 mac, which was too slow, and wanted MPS support

NextDoorLaoHuang-HF avatar Mar 15 '23 13:03 NextDoorLaoHuang-HF

I don't have a Mac or access to one but I will try to implement it.

comfyanonymous avatar Mar 15 '23 16:03 comfyanonymous

Thank you for your positive response, and if you make any progress on this work, I would be more than happy to help you test and provide feedback

NextDoorLaoHuang-HF avatar Mar 15 '23 16:03 NextDoorLaoHuang-HF

Please take this as an example: https://github.com/CompVis/stable-diffusion/compare/main...cruller0704:stable-diffusion-intel-mac:main

I can help test on intel mac.

linonetwo avatar Mar 16 '23 11:03 linonetwo

This would be highly appreciated. I have M1 Mac. And some reasonable python knowledge. I can help, but I need a little guidance how to start.

GaidamakUA avatar Mar 23 '23 11:03 GaidamakUA

Assuming I did things correctly the only functions that need to be changed for MPS (or any other device) support are in this file: https://github.com/comfyanonymous/ComfyUI/blob/master/comfy/model_management.py

comfyanonymous avatar Mar 23 '23 17:03 comfyanonymous

Thank you. Here is pull request. It works on my M1. DDIM sampler doesn't work, because it only accepts cuda device for now. Maybe some other stuff is broken, but basic flow works fine with euler sampler. https://github.com/comfyanonymous/ComfyUI/pull/244

GaidamakUA avatar Mar 24 '23 12:03 GaidamakUA

Can we have tutorial on how to install on Mac / MPS, I will help testing this out. I have M2 Mac Mini.

enzyme69 avatar Mar 24 '23 12:03 enzyme69

I just ran it in virtual environment from AUTOMATIC1111. But instruction for Mac can be useful.

GaidamakUA avatar Mar 24 '23 12:03 GaidamakUA

@enzyme69 Here are instructions for mac from another issue: Assuming you have conda installed:

conda create -n comfyui python=3.10 -y
conda activate comfyui
pip install -r requirements.txt

Run the web interface with:

conda activate comfyui && python ./main.py

GaidamakUA avatar Mar 24 '23 17:03 GaidamakUA

I merged the PR and the DDIM sampler should also work now.

comfyanonymous avatar Mar 24 '23 18:03 comfyanonymous

@comfyanonymous Thank you. I guess, you can close issue now.

GaidamakUA avatar Mar 24 '23 19:03 GaidamakUA

ok make another issue if there's a specific problem with MPS support.

comfyanonymous avatar Mar 24 '23 22:03 comfyanonymous

conda activate comfyui && python ./main.py

thanks!

or2008 avatar Mar 26 '23 14:03 or2008