ControlNet icon indicating copy to clipboard operation
ControlNet copied to clipboard

Add mps-cpu Support

Open Tps-F opened this issue 2 years ago • 6 comments

Summary

・Adapted stablediffusion to work on M1 mac(mps) and CPU

Currently not feasible

・gradio_seg2image.py(Reason:aten::_slow_conv2d_forward is currently not supported by mps.)

Tps-F avatar Feb 16 '23 05:02 Tps-F

@lllyasviel Sorry to be so busy, but can I get a review? I want to help more people use this

Tps-F avatar Feb 20 '23 03:02 Tps-F

I am trying to test this on an M1 Mac, but am experiencing issues with the conda environment configuration. I would recommend adding an environment.yaml targeted for MPS/CPU.

In order to get the conda environment to install correctly, I had to remove cudatoolkit (doesn't exist for Mac) and change versions for python, pip, and opencv-contrib-python. I also needed rust (it wasn't already on my system) in order to get some of the pip packages to install, but not ready to suggest this is necessary.

dependencies:
-  - python=3.8.5
-  - pip=20.3
-  - cudatoolkit
+  - python=3.8
+  - pip=22.3
+  - rust
  - pip:
-      - opencv-contrib-python==4.3.0.36
+      - opencv-contrib-python

With those changes, I was finally able to activate the conda environment and launch the gradio_scribble2image.py example.

However, when trying to "run" the example, I get an AssertionError that originates from cldm/ddim_hacked.py:97 stating that "Torch not compiled with CUDA enabled" even though I am not trying to run with CUDA (I made sure to set PYTORCH_ENABLE_MPS_FALLBACK=1 when launching).

justinseibert avatar Feb 24 '23 20:02 justinseibert

I forgot about it. Thanks for pointing that out!

However, when trying to "run" the example, I get an AssertionError

I found the cause and will fix it now.Sorry

Tps-F avatar Feb 25 '23 01:02 Tps-F

@justinseibert The fix is in! Thanks for your help

Tps-F avatar Feb 25 '23 01:02 Tps-F

@lllyasviel Can you merge this PR as soon as possible, I also encountered this problem locally, thanks

yuanzhixiang avatar Mar 11 '23 15:03 yuanzhixiang

i very hope pip install controlnet can also support macOS, thanks!

Bruce-shuai avatar Mar 16 '23 07:03 Bruce-shuai

dependencies:
  - pip:
-      - opencv-contrib-python==4.3.0.36
+      - opencv-contrib-python

Take the chance to also replace opencv-contrib-python with opencv-contrib-python-headless, it skips some nasty glib deps.

tcmaps avatar Aug 06 '23 12:08 tcmaps