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

[Bug]: MacOS RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Open MagicTide opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [ ] I have searched the existing issues and checked the recent builds/commits

What happened?

Applying cross attention optimization (InvokeAI).
Error completing request
Arguments: ('testjack', '0.005', 1, '/Users/XXX/Documents/traintest_out', 'textual_inversion', 512, 512, 20000, 100, 500, '/Users/XXX/Documents/stable-diffusion-webui/textual_inversion_templates/subject_filewords.txt', True, False, 'testjack', '', 20, 0, 7, -1.0, 512, 512) {}
Traceback (most recent call last):
  File "/Users/XXX/Documents/stable-diffusion-webui/modules/ui.py", line 185, in f
    res = list(func(*args, **kwargs))
  File "/Users/XXX/Documents/stable-diffusion-webui/webui.py", line 56, in f
    res = func(*args, **kwargs)
  File "/Users/XXX/Documents/stable-diffusion-webui/modules/textual_inversion/ui.py", line 33, in train_embedding
    embedding, filename = modules.textual_inversion.textual_inversion.train_embedding(*args)
  File "/Users/XXX/Documents/stable-diffusion-webui/modules/textual_inversion/textual_inversion.py", line 303, in train_embedding
    loss = shared.sd_model(x, c)[0]
  File "/Users/XXX/Documents/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1423, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Users/XXX/Documents/stable-diffusion-webui/repositories/stable-diffusion/ldm/models/diffusion/ddpm.py", line 879, in forward
    return self.p_losses(x, c, t, *args, **kwargs)
  File "/Users/XXX/Documents/stable-diffusion-webui/repositories/stable-diffusion/ldm/models/diffusion/ddpm.py", line 1030, in p_losses
    logvar_t = self.logvar[t].to(self.device)
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Steps to reproduce the problem

  1. Go to Stable Diffusion UI to train embedding
  2. when dataset was prepared, the problem show up 截屏2022-11-10 14 30 50

What should have happened?

  • Training at a normal pace
  • Incidentally, what is the approximate normal speed in s/it?
  • Device: macOS m1 Max 32GB

What platforms do you use to access UI ?

MacOS

What browsers do you use to access the UI ?

Google Chrome

MagicTide avatar Nov 10 '22 06:11 MagicTide

Duplicate of https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3958

aliencaocao avatar Nov 10 '22 11:11 aliencaocao

See https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3958#issuecomment-1296081445 for workaround Or see https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3958#issuecomment-1309806993 for possible cause. TLDR do the workaround edit or downgrade your pytorch to +cu113

aliencaocao avatar Nov 10 '22 11:11 aliencaocao