lllyasviel / ControlNet

Let us control diffusion models!
Apache License 2.0
29.54k stars 2.67k forks source link

MacOS? #64

Open koen330 opened 1 year ago

koen330 commented 1 year ago

Is ControlNet compatible with MacOS. I could install it, and see it in the webUI, but when I use it, I get following error:

Loading preprocessor: canny, model: control_sd15_canny [fef5e48e] Loaded state_dict from [/Users/koen/Documents/SD/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_sd15_canny.pth] ControlNet model control_sd15_canny [fef5e48e] loaded. 0%| | 0/16 [00:00<?, ?it/s]loc("mps_add"("(mpsFileLoc): /AppleInternal/Library/BuildRoots/a0876c02-1788-11ed-b9c4-96898e02b808/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShadersGraph/mpsgraph/MetalPerformanceShadersGraph/Core/Files/MPSGraphUtilities.mm":219:0)): error: input types 'tensor<2x1280xf32>' and 'tensor<*xf16>' are not broadcast compatible LLVM ERROR: Failed to infer result type(s). zsh: abort ./webui.sh koen@Koens-MacBook-Pro-2 stable-diffusion-webui % /opt/homebrew/Cellar/python@3.10/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d '

Shortly after "Python quit unexpectedly"

Koen

Ohnopleaseno commented 1 year ago

Hi,

I have the exact same issue on my Macbook air M1. I hope we'll find a fix, because ControlNet is for sure a game changer.

JacopoMangiavacchi commented 1 year ago

I saw others had a very similar problem trying to use OAI Whisper model with Apple Silicon. Apparently the model is expecting a 32bit float tensor but it receives a 16bit tensor and MPS is not automatically converting/broadcasting. I haven’t tried but according to this post someone solve the problem configuring the fp32 version of the model and using the CPU :/

https://news.ycombinator.com/item?id=32928966

Hope there’s a better way

enzyme69 commented 1 year ago

If using Automatic1111, --no-half maybe works: https://github.com/Mikubill/sd-webui-controlnet

I did test it and it actually works. Maybe just a bit slower. Using M2 Pro machine, 16 GB.

Ohnopleaseno commented 1 year ago

Thanks @enzyme69 it actually works! I'm so happy.

Additional info in case a noob like me is reading this. You need to open the file "webui-user.sh" in your stable-diffusion-webui folder. Then you'll find a line with written "#COMMANDLINE_ARGS=""

Remove the "#" and write "--skip-torch-cuda-test --no-half" Eventually the line should look like "COMMANDLINE_ARGS="--skip-torch-cuda-test --no-half"

About the first argument, I had to add it as well, otherwise the program was crashing and was explicitly saying I should add it.

A picture is taking me around 3 minutes (20 steps) on my macbook M1 Air - 16 GB. I didn't need to check "Low VRAM" as a comment on r/stablediffusion implied, however not doing so is making the render about 1 minute longer.

kevinhower commented 1 year ago

That commandline args thing worked! At least on my M1 machine. Thanks so much! This is awesome :)

ezam0000 commented 1 year ago

--no-half

works!

jgranie commented 1 year ago

Don't work for me, I get the same error with --no-half on M1, I also have a warning torch 1.12.1 instead of 1.13.1 is it the cause of the issue ?

During the init:

Launching Web UI with arguments: --no-half
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
No module 'xformers'. Proceeding without it.
==============================================================================
You are running torch 1.12.1.
The program is tested to work with torch 1.13.1.

During the generation: RuntimeError: Input type (MPSFloatType) and weight type (torch.FloatTensor) should be the same

Mikubill commented 1 year ago

You should use webui.sh/webui-user.sh to startup and arguments will be filled like: --upcast-sampling --no-half-vae --use-cpu interrogate —no-half...

jgranie commented 1 year ago

Thanks for your quick reply, I have the same issue with these parameters (the exact line I have in my web-user.sh is:export COMMANDLINE_ARGS="--upcast-sampling --no-half-vae --use-cpu interrogate --skip-torch-cuda-test --no-half") and I launch SD with webui.sh

EDIT: The parameters solve the issue with depth preprocessor, I tried only the new depth_leres yesterday. Someone has the same issue ?

SteakTree commented 1 year ago

Don't work for me, I get the same error with --no-half on M1, I also have a warning torch 1.12.1 instead of 1.13.1 is it the cause of the issue ? I thought that this may be an issue but apparently, Mac should use Torch 1.12.1 according to this thread https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/7495

linusqqqq commented 1 year ago
Bildschirmfoto 2023-07-17 um 19 18 09

Please help. It is still not working for me. M1 Air 8GB

AlanZhou2022 commented 1 year ago

Is the problem solved now?