Move To Device
The tiny node that fixes tensors sitting on the wrong hardware
- data
- IMAGE
Move To Device does one thing: it takes a tensor, picks it up, and puts it on the hardware ComfyUI is actually computing on - your GPU if one is available, CPU if not. One IMAGE in, one IMAGE out. That's the entire job, and it's a job you'll rarely need done in modern ComfyUI.
Here's why you'd reach for it anyway. Custom nodes are not all written equal. Some third-party loaders and preprocessors compute on the CPU and forget to move their output to CUDA before passing it along. The next node down the line assumes it's on the GPU and throws the classic "Expected all tensors to be on the same device" error - or, worse, silently shoves everything onto the CPU and your video pass crawls. Sticking Move To Device right after the offending node forces its output onto the active device before anything downstream touches it. It's a rescue node, not a daily driver, and that's fine: it's ten seconds to insert and it saves you from hunting through a graph for the node that leaked a CPU tensor.
How it works
The source calls ComfyUI's get_torch_device() - the same call the engine uses to decide GPU-versus-CPU - and moves the tensor there. It's also built to survive nested structures: the code recurses through lists, tuples, and dicts, moving any tensors it finds inside. That's more robust than the socket lets on, since the exposed input is declared as IMAGE. Two things it deliberately does not do: it won't change the data type (a fp16 tensor stays fp16; to(device) doesn't cast) and it won't change the shape. Move-only. If your problem is a dtype mismatch or an OOM, this node is not the fix - OOM is a VRAM budget problem, and dtype mismatch needs a cast node instead.
The classic spot I've seen it earn its keep is video pipelines, where frame tensors shuttle between a CPU-side loader and a GPU-side encoder and a single node in the chain forgets to hop the fence. Slip this in at the boundary and the mismatch errors stop.
Installing it
Same as every node in this pack: ComfyUI Manager (search comfyui-inputswitch), or clone into custom_nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/bmgjet/comfyui-inputswitch.git
Restart after the first load, because the pack's auto-installer runs once and wants a fresh start. Fair warning on install weight: this pack pins torch==2.9.1 and pulls in kornia, onnxruntime-gpu, and OS-specific insightface/numpy wheels. If you're here just for Move To Device, that's a lot of machinery for a one-liner - a lighter alternative is ComfyUI's own built-in plumbing or just fixing the node upstream that forgot to move its output. But if the pack is already in your install for its RIFE or face-swap nodes, Move To Device is free and occasionally priceless.
Troubleshooting
- It didn't change anything: if ComfyUI is already on GPU and the tensor was too, there's nothing to do - the node is a no-op by design. That's correct behavior, not a bug.
- Error still happens after inserting it: check the tensor's dtype. If the complaint is fp16 vs fp32 rather than device, Move To Device can't help; use a cast node instead.
- Everything runs but it's slow: if you're on a CPU-only install, moving tensors is a no-op and the slowdown is your hardware, not the node.
It's not a glamorous node. It doesn't generate anything and it won't make your images better. But the day a shared workflow crashes on a device error and you've got one of these in your back pocket, you'll be glad it's there.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| data | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |