Hi everyone,
I’m encountering an issue when running my code on Space using ZeroGPU. I’ve set .to("cuda") on the pipeline, but I can’t figure out what’s going wrong. Locally, with two A100 GPUs, everything works fine.
Here is the complete error I’m getting:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/spaces/zero/wrappers.py", line 256, in thread_wrapper
res = future.result()
File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result
return self.__get_result()
File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, *kwargs)
File "/home/user/app/app.py", line 49, in infer
image = pipe(
File "/usr/local/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/diffusers/pipelines/flux/pipeline_flux.py", line 684, in __call__
latents, latent_image_ids = self.prepare_latents(
File "/usr/local/lib/python3.10/site-packages/diffusers/pipelines/flux/pipeline_flux.py", line 522, in prepare_latents
latent_image_ids = self._prepare_latent_image_ids(batch_size, height // 2, width // 2, device, dtype)
File "/usr/local/lib/python3.10/site-packages/diffusers/pipelines/flux/pipeline_flux.py", line 431, in _prepare_latent_image_ids
latent_image_ids[..., 1] = latent_image_ids[..., 1] + torch.arange(height)[:, None]
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
It seems the issue is due to tensors being on different devices, in this case cuda:0 and cpu. I’ve checked my code and I believe I’ve transferred everything to cuda, so I’m not sure what I’m missing.
Has anyone experienced similar issues or have any suggestions on how to resolve this? Any help would be greatly appreciated!
Thanks in advance!