Live data from Hacker News

Run Stable Diffusion on Your M1 Mac’s GPU

replicate.com

131–140 of 415 posts

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

#131
post #103

The difference between an M2 air (8gb/512gb) versus an M1 pro (16gb/1tb) is much more than I expected. * M1 pro (16gb/1tb) can run the model in around 3 minutes. * M2 air (8gb/512gb) takes ~60 minutes for the same model. I knew there would be some throttling due to the m2 air's fanless model, but I had no idea it would be a 20x difference (albeit, the m1 pro does have double the RAM. I don't have any other macbooks t…

I suspect that the M2 air is thrashing the disk pretty aggressively. Diffusion models rerun the same model once per step, so for a generation with 50 steps, you copy the entire model in and out of memory 50 times. That's going to kill performance.

It's only copied to VRAM once when implemented correctly.

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

#133

Anyone know the largest possible image size > 512x512? I'm getting the following error when trying 1024x1024 with 64 GB RAM on M1 MAX: /opt/homebrew/Cellar/python@3.10/3.10.6_2/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 appea…

I have the same problem with anything over 512x512 on my M1 Ultra with 128GB. VRAM must be capped.

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

#134

Anyone know the largest possible image size > 512x512? I'm getting the following error when trying 1024x1024 with 64 GB RAM on M1 MAX: /opt/homebrew/Cellar/python@3.10/3.10.6_2/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 appea…

Don't specifically know sorry, largest I can generate with my (windows pc) vram size is 512x1024. But just wanted to comment that SD is trained on 512x512 images and runs iterations in a 512x512 window.

This means anything larger than 512x512 tends to confuse it. For example 1024x1024 will have 4 non-overlapping windows and many overlapping windows.

So if your prompt is "a cat wearing sunglasses", you may get 4 separate cats as the 512x512 windows have no knowledge of each other, and each window is trying to fulfill the goal. Even more likely you'll get some sort of eldrtich horror 16-legged cat being as the windows shuffle around.

Sometimes it just works perfectly somehow, but 90% of the time the non native resolution really screws it up. I'd suggest generating 512x512 images and using a different AI to upscale them in most cases.

However it does lead to some amazing fantasy landscape art as you get weird terrains and mountains shoved up against eachother in fantastic/magical ways.

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

#135

Earlier quoted context omitted.

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

For 512x512 on M1 MAX (32 core) with 64 GB RAM I'm getting 1.67it/s so 30.59s with the default ddim_steps=50.

I've gotten 1.35it/s that corresponds to 38s, but I've the M1 Max with the 24 cores GPU (the "lower end" one).

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

#137
It's insane to me how fast this is moving. I jumped through a bunch of hoops 2-3 days ago to get this running on my M1 Mac's GPU and now it's way easier. I imagine we will have a nice GUI (I'm aware of the web-ui, I haven't set it up yet) packaged in an mac .app by the end of next week. Really cool stuff.

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

#138
post #90

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…

Nice. We'll get this guide updated for this fork. Everything's moving so fast it's hard to keep track! We struggled to get Conda working reliably for people, which it looks like lstein's fork recommends. I'll see if we can get it working with plain pip.

I really appreciate the use of pip > conda. Looking forward to the update for the repo!

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

#139
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.

This model was mostly trained on 512x512 so you should stick to approximately that size.

Use external upscalers like RealESRGAN, SwinIR or BSRGAN or GFPGAN (faces).

Alternatively use hacks like txt2imghd to get it to natively create 1 MP images.

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

#140

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-d…

The RX6800 seems like a great card for this - 16GB of relatively fast VRAM for a good price.

How long does it take to do 50 iterations on a 512x512?

Post reply on HN