Live data from Hacker News

Run Stable Diffusion on Your M1 Mac’s GPU

replicate.com

231–240 of 415 posts

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

#231
Bananas. Thanks so much... to everyone involved. It works.

14 seconds to generate an image on an M1 Max with the given instructions (`--n_samples 1 --n_iter 1`)

Also, interesting/curious small note: images generated with this script are "invisibly watermarked" i.e. steganographied!

See https://github.com/bfirsh/stable-diffusion/blob/main/scripts...

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

#232
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

For me `--full-precision` kept erroring out, but `--precision full` worked correctly.

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

#233
post #197

Earlier quoted context omitted.

are there benchmarks? I was following the github issue and the CPU bound one was at 4-5 minutes, the MDS one was at 30 seconds, then 18 seconds, and people were still calling that slow. What is it currently at now? and I don't know what "fast" is, to compare What are the Windows 10 with nice Nvidia chips w/ CUDA getting? Just curious whats comprehensive

Wait, what? On my M1 imac I’m getting about 25 minutes . What am i doing wrong?

It's falling back to CPU. Follow the instructions to use a GPU version - sometimes it's even a completely different repo, depending on whose instructions you're following.

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

#234

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.

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

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

#235
post #142

Earlier quoted context omitted.

Running lstein's fork with these requirements[0] but seeing this output[1]. Same steps as original guide otherwise. Anyone got any ideas? [0] https://github.com/bfirsh/stable-diffusion/blob/392cda328a69... [1] https://gist.github.com/bfirsh/594c50fd9b2e6b173e31de753a842...

Same output for me also. EDIT: https://github.com/lstein/stable-diffusion/issues/293#issuec... fixed it for me.

Boom - nice. Here's a fork with that: https://github.com/bfirsh/stable-diffusion/tree/lstein

Requirements are "requirements-mac.txt" which'll need subbing in the guide.

We're testing this out with a few people in Discord before shipping to the blog post.

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

#236

Earlier quoted context omitted.

Unscientifically that puts the M1 Pro GPU at about 25% of the performance of a RTX 3080. Not too shabby... EDIT - this comment implies it's much faster: https://news.ycombinator.com/item?id=32679518 If that's correct then it's close to matching my 3080 (mobile).

It's likely that a significant fraction of the perf difference between Apple' GPUs and NVIDIA GPUs is due to NVIDIA's CUDA being high optimized, and Pytorch being tuned to work with CUDA. If Pytorch's metal support improves and Apple's Metal drivers improve (big ifs), it's likely that Apple's GPUs will perform better relatively to NVIDIA than they currently do.

[deleted]

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

#237
post #197

Earlier quoted context omitted.

Wait, what? On my M1 imac I’m getting about 25 minutes . What am i doing wrong?

It's falling back to CPU. Follow the instructions to use a GPU version - sometimes it's even a completely different repo, depending on whose instructions you're following.

I followed https://replicate.com/blog/run-stable-diffusion-on-m1-mac

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

#238
post #230

Running into this error `RuntimeError: expected scalar type BFloat16 but found Float` when I run `txt2img.py`

SOLUTION - append the command with `--precision full`

Awesome, that works

For reference the full command:

`python scripts/txt2img.py \ --prompt "a red juicy apple floating in outer space, like a planet" \ --n_samples 1 --n_iter 1 --plms --precision full`

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

#239
post #222

Earlier quoted context omitted.

Yes, me too! Please post here if you find a solution for all the other people that come and find this by commmand-F'ing this error

I'm stuck on 'RuntimeError: expected scalar type BFloat16 but found Float' too. Most relevant links seems https://github.com/CompVis/stable-diffusion/pull/47 but I'm not sure. Please post when there is a solution.

That might have to do with your Mac OS version. Pre-12.4 Mac OS does not allow the Torch backend to use the M1 GPU, and so the script attempts to use the cpu, but then the cpu does not support half-precision numbers.

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

#240

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.

A little over three minutes on a first-gen M1 iMac with 16GB.

It looks like memory is super-important for this (which isn't all that surprising, really...).

Post reply on HN