Super Resolution: Expected all tensors to be on the same device
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 155
Description
The new [Super Resolution node](https://github.com/comfyanonymous/ComfyUI/commit/3f75419e2e656575309f391769c66813a9ec078d#diff-3461a6b32a46ecebc5f2060da70991375489a6f41fd96d84e77c1039326f1f12R105) fails with the error below:
```python
File ".../ComfyUI/execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../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 ".../ComfyUI/execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ComfyUI/comfy_extras/nodes_stable_cascade.py", line 125, in generate
controlnet_input = vae.encode(image[:,:,:,:3]).movedim(1, -1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ComfyUI/comfy/sd.py", line 317, in encode
samples[x:x+batch_number] = self.first_stage_model.encode(pixels_in).to(self.output_device).float()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ComfyUI/comfy/ldm/cascade/stage_c_coder.py", line 92, in encode
return self.encoder(x)
^^^^^^^^^^^^^^^
File ".../ComfyUI/pytorch-5.7/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1519, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ComfyUI/pytorch-5.7/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1528, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../ComfyUI/comfy/ldm/cascade/stage_c_coder.py", line 37, in forward
x = (x - self.mean.view([3,1,1])) / self.std.view([3,1,1])
~~^~~~~~~~~~~~~~~~~~~~~~~~~
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
```
Adding prints of the relevant `device` fields just prior to this calculation gives the following:
```
x.device=device(type='cuda', index=0)
self.mean.device=device(type='cpu')
self.std.device=device(type='cpu')
```
Seems like the default `cpu` device in the `__init__()` method is not getting overridden with the correct device.
[super_res.json](https://github.com/comfyanonymous/ComfyUI/files/14551049/super_res.json)
System: AMD 5900X CPU and AMD RX7600 GPU 8GB. ComfyUI started with `--disable-smart-memory --novram`
Contributor guide
Assessment
This issue has not been assessed yet.