RuntimeError: expected scalar type BFloat16 but found Float

#42
by Ringerill - opened

Hello,

As the title states, I'm running into this error when trying to generate images with the default parameters using a CPU on Mac.

Setting --precision to be 'full' seems to help.

We will merge a PR that makes sure SD can be run on Mac tomorrow: https://github.com/huggingface/diffusers/pull/355

Setting --precision to be 'full' seems to help.

@aduranel , I think we do not launch the jobs in the same way so I'm a little bit lost as to where this argument should be called.
Would you mind indicating what function actually allows this?

Hmm. In txt2img.py, around line 238, there is a block like this:

parser.add_argument(
"--precision",
type=str,
help="evaluate at this precision",
choices=["full", "autocast"],
default="autocast"
)

Changing the default to "full" helped me when I encountered this error.

@aduranel Ok now I am very confused and probably I'm not even doing it right...
I've been using the StableDiffusionPipeline function from diffusers as shown in the example.
I though that at some point the Stable diffusion functions were called in the background but am I simply mistaken and not even in the good repo here?

Sorry, I've been trying different repo for the whole day to make it work on Mac and I might have mixed some things...

Possibly you use autocast("cuda") when working with cpu? Then it should be autocast("cpu") (and I think you can only use 32bit floats on the cpu).

Setting --precision to be 'full' seems to help.

this worked for me. thanks!

Hmm. In txt2img.py, around line 238, there is a block like this:

parser.add_argument(
"--precision",
type=str,
help="evaluate at this precision",
choices=["full", "autocast"],
default="autocast"
)

Changing the default to "full" helped me when I encountered this error.

where is txt2img.py in?

Hi,

I'm running this code on a A10 instance. I dont have precision parameter here. Is there any way to fix this? and this is the code Im running. It raises error in the training part: https://colab.research.google.com/drive/1DqKNPOzyMUXmJiJFvJITOahVDxCrA-wA#scrollTo=wShqQoppuv-h

@dgfhn They(we) run in this issue when trying to follow example for stablediffusion: https://github.com/Stability-AI/stablediffusion

For others like me just trying to do the example, without touching the code, "--precision full" can be added in the command line:

python scripts/txt2img.py --prompt "a professional photograph of an astronaut riding a horse" --ckpt ~/Downloads/v2-1_512-ema-pruned.ckpt --config configs/stable-diffusion/v2-inference-v.yaml --H 768 --W 768  --precision full

Sign up or log in to comment