Live data from Hacker News

Run Stable Diffusion on Your M1 Mac’s GPU

replicate.com

71–80 of 415 posts

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#71
post #66
post #53

Does running it locally give you anything over using the web version?

You can hack on it, modify it, integrate it with other code, etc!

Also, of course, it's entirely free. The web version is actually paid, though it's hard to tell because they're not super transparent about the fact that you're steadily eating through a quota of initial tokens.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#72
post #56
post #51

Hm, when I run the example, I get this error: > expected scalar type BFloat16 but found Float Has anyone seen this error? It's pretty hard to google for.

Yeah. Try running with PYTORCH_ENABLE_MPS_FALLBACK=1 --full-precision

This worked!

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#73

Has anybody had success getting newer AMD cards working? ROCm support seems spotty at best, I have a 5700xt and I haven't had much luck getting it working.

I have it working on an RX 6800, used the scripts from this repo[0] to build a docker image that has ROCm drivers and PyTorch installed.

I'm running Ubuntu 22.04 LTS as the host OS, didn't have to touch anything beyond the basic Docker install. Next step is build a new Dockerfile that adds in the Stable Diffusion WebUI.[1]

[0] https://github.com/AshleyYakeley/stable-diffusion-rocm [1] https://github.com/hlky/stable-diffusion-webui

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#74
post #13

How large an image will this handle (versus how much RAM you have)? It seems the GPU memory requirements beyond 512x512 are obscene.

Me at the end of last year: "Should I really go for the full 64GB on this M1 Pro? What could I possibly use this for? mmbml mumble... something about unified GPU... something Deep Learning, one day..."

Me now: "a red juicy apple floating in outer space, like a planet" --H 768 --W 768

Uses about 27GB. 1.81s/it.

Can't do 1024x1024 yet because of some hardcoded Metal issue (https://github.com/pytorch/pytorch/issues/84039.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#75

Earlier quoted context omitted.

What kind of speed does this run at? Eg. How long to make a 512x512 image at standard settings?

I haven't installed from this link specifically, but I used one of the branches on which this is based a few days ago, so the results should be similar. On a first-gen M1 Mac mini with 8GB RAM, it takes 70-90 minutes for each image. Still feels like magic, but old-school magic.

On an M1 Pro 16GB it is taking a couple minutes for each image.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#76

Magnusviri[0], the original author of the SD M1 repo credited in this article, has merged his fork into the Lstein Stable Diffusion fork. You can now run the Lstein fork[1] with M1 as of a few hours ago. This adds a ton of functionality - GUI, Upscaling & Facial improvements, weighted subprompts etc. This has been a big undertaking over the last few days, and I highly recommend checking it out. See the mac m1 readme…

Brilliant, thank you! I just got OP's setup working, but this seems much more user-friendly. Giving it a try now...

EDIT: Got it working, with a couple of pre-requisite steps:

0. `rm` the existing `stable-diffusion` repo (assuming you followed OP's original setup)

1. Install `conda`, if you don't already have it:

    brew install --cask miniconda
2. Install the other build requirements referenced in OP's setup:

    brew install Cmake protobuf rust
3. Follow the main installation instructions here: https://github.com/lstein/stable-diffusion/blob/main/README-...

Then you should be good to go!

EDIT 2: After playing around with this repo, I've found:

- It offers better UX for interacting with Stable Diffusion, and seems to be a promising project.

- Running txt2img.py from lstein's repo seems to run about 30% faster than OP's. Not sure if that's a coincidence, or if they've included extra optimisations.

- I couldn't get the web UI to work. It kept throwing the "leaked semaphor objects" error someone else reported (even when rendering at 64x64).

- Sometimes it rendered images just as a black canvas, other times it worked. This is apparently a known issue and a fix is being tested.

I've reached the limits of my knowledge on this, but will following closely as new PRs are merged in over the coming days. Exciting!

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#77
post #21

For those as keen as I am to try this out, I ran these steps, only to run into an error during the pip install phase: > ERROR: Failed building wheel for onnx I was able to resolve it by doing this: > brew install protobuf Then I ran pip install again, and it worked!

What kind of speed does this run at? Eg. How long to make a 512x512 image at standard settings?

M1 Max (32gb) is around 35 seconds per image.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#78

Thanks for this - it's rare to see a setup guide that actually works on each step! I did need to run the troubleshooting step too, could probably just move that up as a required step in the guide.

It isn't required for some (most?) users. Weirdly sometimes pip is picking up the wheel for `onnx`, sometimes it isn't, and we can't figure out why.

Any Python packaging experts know what's going on? all macOS 12, arm64, Python 3.10. Can't think it wouldn't resolve the wheel.

But yes, good idea to move up. I'll stick it next to the `pip install`.

Re: Run Stable Diffusion on Your M1 Mac’s GPU

#79
post #28

Earlier quoted context omitted.

I got stuck on this roadblock, couldn’t get CUDA to work on my Mac, was very confusing

Didn’t apple stop supporting Nvidia cards like 5 years ago? How could it be confusing that Cuda wouldn’t run?

lol presumably the OP didn't know that... hence the confusion.
Post reply on HN