kijai / ComfyUI-SUPIR

SUPIR upscaling wrapper for ComfyUI
Other
1.58k stars 87 forks source link

Error: Expected all tensors to be on the same device #79

Open TimothyKrell opened 7 months ago

TimothyKrell commented 7 months ago

I keep getting the following error when the SUPIR Sampler runs:

Error occurred when executing SUPIR_sample:

Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

File "C:\Users\timot\Code\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "C:\Users\timot\Code\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "C:\Users\timot\Code\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "C:\Users\timot\Code\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-SUPIR\nodes_v2.py", line 443, in sample
_samples = self.sampler(denoiser, noised_z, cond=positive[i], uc=negative[i], x_center=sample.unsqueeze(0), control_scale=control_scale_end,
File "C:\Users\timot\Code\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\diffusionmodules\sampling.py", line 638, in __call__
x, s_in, sigmas, num_sigmas, cond, uc = self.prepare_sampling_loop(
File "C:\Users\timot\Code\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-SUPIR\sgm\modules\diffusionmodules\sampling.py", line 53, in prepare_sampling_loop
x *= torch.sqrt(1.0 + sigmas[0] ** 2.0)

What might be causing this? I've tried adding --gpu-only and --disable-cuda-malloc, but they haven't fixed the issue.

Workflow: supir-test.json

kijai commented 7 months ago

The denoiser output is not meant to be sampled directly, but encoded again... or so they originally had it, I'm unsure if it is necessary though. I need to change the device of that output so it can be tested, but this is how the original setup is:

image

kijai commented 7 months ago

Ok, your setup is now acceptable too in latest version, pushed simple fix. I do not know if it's good or bad idea, you'd need to test and compare.

TimothyKrell commented 7 months ago

Ah. OK. Re-encoding it worked. I'll try it with the update and see if there's any difference.