Live data from Hacker News

Run Stable Diffusion on Your M1 Mac’s GPU

replicate.com

251–260 of 415 posts

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

#251

I've been playing with Stable Diffusion a lot the past few days on a Dell R620 CPU (24 cores, 96 GB of RAM). With a little fiddling (not knowing any python or anything about machine learning) I was able to get img2img.py working by simply comparing that script to the txt2img.py CPU patch. Was only a few lines of tweaking. img2img takes ~2 minutes to generate an image with 1 sample and 50 iterations, txt2img takes abo…

With the 1.4 checkpoint, everything under 40 steps can't be used basically and you only get good fidelity with >75 steps. I usually use 100, that's a good middleground.

I found I got quite decent results with 15-30 steps when generating children’s book illustrations (of course, no expectation for hyperrealism there)

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

#253

Earlier quoted context omitted.

With the 1.4 checkpoint, everything under 40 steps can't be used basically and you only get good fidelity with >75 steps. I usually use 100, that's a good middleground.

How do you change these steps in the given script? Is it the --ddim_steps parameter? Or --n_iter? Or ... ?

With --ddim_steps

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

#255
post #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 inst…

Thank you with those extra steps I got it working now myself. At least I think thank you. My work productivity for the next few days might not agree.

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

#256

What's this log message about when generating an image? Creating invisible watermark encoder (see https://github.com/ShieldMnt/invisible-watermark )...

See my sibling comment here https://news.ycombinator.com/item?id=32684003 :-)

The code that generates it is here: https://github.com/bfirsh/stable-diffusion/blob/main/scripts...

You can remove `img = put_watermark(img, wm_encoder)` which appears at lines 317 and 333 to get rid of the watermarking.

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

#257
post #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 inst…

FYI: black images are not just from the safety checker.

Yes, the safety checker will zero out images but can just turn it off with an “if False:”; Mostly black images are due to a bug, especially frustrating because it turns up on high step counts and means you’ve wasted time running it.

My experience has been roughly 2-4/32 of an image batch comes back black at the default settings, regardless of the prompt.

Just stamp out images in batches and discard the black ones.

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

#258
post #135

Earlier quoted context omitted.

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).

I just set up a similar thing on my own a bit differently than OP did.

Apple M1 Max with 10-core CPU, 32-core GPU, 16-core Neural Engine - Takes 38 seconds as well up to 46 when it gets hotter.

Can anyone give comparison with Nvida gpu in terms of performance?

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

#259
post #176

I'm working on getting this running. Instead of "venv/bin/activate" I had to run "source venv/bin/activate". And I got an error installing the requirements, fixed by running "pip install pyyaml" as a separate command.

There's a little "." before "venv/bin/activate" that's easy to miss. I'll update it to "source" to make it more obvious.

Great. FYI, the issue with pyyaml was caused by the "--pre" flag. The reason installing it separately fixes the problem is because it installs it without the "--pre" flag, and then it is already installed when you install the requirements.

I haven't been able to make sense of n-samples and n-iters. Changing the former caused generation to freeze at 0%. Changing the latter seems to generate multiple images, even though the SD docs for n-iters are "sample this often".

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

#260

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…

I ran into:

ImportError: cannot import name 'TypeAlias' from 'typing' (/opt/homebrew/Caskroom/miniconda/base/envs/ldm/lib/python3.9/typing.py)

Post reply on HN