News for hackers. Stuff that matters.
Re:Run Stable Diffusion on Your M1 Mac’s GPU by vvanirudh on Thursday September 01, 2022 @03:53PM (#32682133)
Running into this error `RuntimeError: expected scalar type BFloat16 but found Float` when I run `txt2img.py`
Re:Run Stable Diffusion on Your M1 Mac’s GPU by yboris on Thursday September 01, 2022 @06:10PM (#32684001)
SOLUTION - append the command with `--precision full`
Re:Run Stable Diffusion on Your M1 Mac’s GPU by sytse on Thursday September 01, 2022 @06:30PM (#32684221)
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 by yboris on Thursday September 01, 2022 @03:59PM (#32682247)
Confirming I'm stuck on the same error when running the tutorial-instructed python scripts/txt2img.py command

    RuntimeError: expected scalar type BFloat16 but found Float
Re:Run Stable Diffusion on Your M1 Mac’s GPU by ml_basics on Thursday September 01, 2022 @04:25PM (#32682622)
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
Re:Run Stable Diffusion on Your M1 Mac’s GPU by sytse on Thursday September 01, 2022 @05:51PM (#32683785)
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.
Re:Run Stable Diffusion on Your M1 Mac’s GPU by alvb on Thursday September 01, 2022 @06:31PM (#32684226)
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 by alvb on Thursday September 01, 2022 @08:06PM (#32685027)
Yep---that was it in my case. I had the same error but it went away after upgrading to MacOS 12.5. You should actually check if your PyTorch installation can detect the mps backend: `torch.backends.mps.is_available()` must be equal to True.