Indices should be either on cpu or on the same device as the indexed tensor (cpu)

Author: yukiimeCreated May 27, 2025Updated Jun 1, 2025

When starting training, line 1043 of ./stable_diffusion/ldm/models/diffusion/ddpm_edit.py logvar_t = self.logvar[t].to(self.device) will result in an error RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

I tried to fix it to logvar_t = self.logvar[t.cpu()].to(self.device) and it could be continued to run.

I wonder if anyone else has encountered this problem ? and what is the reasonable solution to this problem? Is it because of my hardware configuration that this problem is wrong?

Source: timothybrooks/instruct-pix2pix