Stability-AI / stablediffusion

High-Resolution Image Synthesis with Latent Diffusion Models
MIT License
38.33k stars 4.95k forks source link

Shape invalid for input of size #303

Open alexw92 opened 1 year ago

alexw92 commented 1 year ago

I am using stable diffussion with 2.1 weights and execute prompts from a list. However I sometimes get the error

RuntimeError: shape \'[10, 77, 5, 64]\' is invalid for input of size 221760

for some prompts but not for all. For other prompts it works totally fine. I am currently trying to find out which specific prompts trigger it.

Did this happen to anyone else before?

For reference I am running it on WSL and have the dependencies installed in a conda environment.

Andrew0613 commented 1 year ago

Hello, I've come across the same error. I discovered that this runtime issue stems from a shape mismatch between 'q' and 'k' in the cross-attention module. The batch sizes differ between 'q' and 'k' due to the unequal batch sizes between the cues and images. Kindly make sure that the number of your prompts is divisible by 'n_sample' solves the problem.