T2I-Adapter icon indicating copy to clipboard operation
T2I-Adapter copied to clipboard

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

Open qingfengmingyue opened this issue 1 year ago • 3 comments

image

qingfengmingyue avatar Mar 06 '23 10:03 qingfengmingyue

I got the same message while messing with low vram setting to see if that would fix other errors. If you check the low vram setting and then uncheck it, you'll get this error. Have to restart the web gui batch file. Once it loads a model into RAM with low vram turned on, if the vram is turned off, it doesn't remove it from RAM and can't deal with trying to load it on the GPU is my guess.

jmilez avatar Mar 14 '23 02:03 jmilez

i get this error too,have u fix it?

42Viva avatar Jun 01 '23 10:06 42Viva

I encountered a similar issue, but I managed to solve it by modifying the code. Here is the modified code snippet and its output: It appears that the issue stems from providing only the CPU index when accessing the tensor. To resolve this, I made the following modification in the ddpm.py file, specifically at lines 886 and 887: t = t.cpu() logvar_t = self.logvar[t].to(self.device) tensor([441, 685, 211, 261, 824, 473, 524, 818], device='cpu')

By moving the tensor t to the CPU using .cpu() and then bringing self.logvar[t] back to the original device using .to(self.device), the code seems to be running smoothly.

I have opened a GitHub issue to request this change in the code repository. I kindly ask for your attention to this matter and request that the code be updated accordingly.

YangChangHee avatar Jul 06 '23 07:07 YangChangHee