stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Open dmavromatis opened this issue 2 years ago • 6 comments

Describe the bug When I try to generate I get the following error:

Error completing request Arguments: ('Test', '', 'None', 'None', 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 0, 0, 0, False, False, None, '', 1, '', 0, '', True, False, False) {}

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

File "/usr/local/lib/python3.10/site-packages/torch/nn/functional.py", line 2503, in layer_norm return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Mac M1

dmavromatis avatar Oct 15 '22 20:10 dmavromatis

I have the same error after the last git pull

Windows 10

jabelardo avatar Oct 15 '22 20:10 jabelardo

Makes sense -- because I had generated 1 successfully, this morning -- then started it back up and got that error.

dmavromatis avatar Oct 15 '22 20:10 dmavromatis

modules\textual_inversion\image_embedding.py, insert_image_data_embed(),

change

    data_np_low.resize(next_size)
    data_np_low = data_np_low.reshape((h, -1, d))

    data_np_high.resize(next_size)
    data_np_high = data_np_high.reshape((h, -1, d))

to

    np.resize(data_np_low,next_size)
    data_np_low = data_np_low.reshape((h, -1, d))

    np.resize(data_np_high, next_size)
    data_np_high = data_np_high.reshape((h, -1, d))

cobryan05 avatar Oct 16 '22 16:10 cobryan05

The solution is mentioned here: https://github.com/Birch-san/stable-diffusion#patch

all what you have to do is going the file mentioned by the error, i.e. from cli: open /usr/local/lib/python3.10/site-packages/torch/nn/functional.py or in my ios case in a conda env: open /opt/homebrew/Caskroom/miniforge/base/envs/web-ui/lib/python3.10/site-packages/torch/nn/functional.py

and when it opens go to the mentioned line 2503 to change input to input..contiguous()

save, rerun the app and it worked 👍

the problem appeard on my mac M1 but not on colab

soulayman-al-abdallah avatar Oct 25 '22 14:10 soulayman-al-abdallah

Happened to me today on m2 macbook air.

dgolant avatar Nov 07 '22 20:11 dgolant

Happened to me today on m1pro MacBook Pro.

lzhbhlrPython avatar Nov 24 '22 15:11 lzhbhlrPython

The solution is mentioned here: https://github.com/Birch-san/stable-diffusion#patch

all what you have to do is going the file mentioned by the error, i.e. from cli: open /usr/local/lib/python3.10/site-packages/torch/nn/functional.py or in my ios case in a conda env: open /opt/homebrew/Caskroom/miniforge/base/envs/web-ui/lib/python3.10/site-packages/torch/nn/functional.py

and when it opens go to the mentioned line 2503 to change input to input..contiguous()

save, rerun the app and it worked 👍

the problem appeard on my mac M1 but not on colab

this worked for me, however looks like it has been fixed already in torch 1.13.1

ersingencturk avatar Dec 21 '22 15:12 ersingencturk