Image Change Device
Move an Image Tensor Between CPU and GPU
- image
- image
Every tensor in a PyTorch-based pipeline lives on a specific device - the CPU, or a particular GPU - and an operation that touches two tensors on different devices will refuse to run rather than guess what you meant. Image Change Device is the manual override for that: point it at an image and a target device, and it moves the tensor there, no questions asked. It's not exciting, but it's the kind of node that turns a "runtime error: tensors on different devices" crash into a non-event.
There are exactly two inputs. image is whatever you're moving. device is a dropdown with five choices: default (don't intervene, ComfyUI's normal placement), cpu, cuda (the default GPU), and explicit cuda:0 / cuda:1 for picking a specific card on a multi-GPU machine. The output is image, same content, relocated. That's the entire node.
Realistic reasons to reach for it: you're running a multi-GPU rig locally and want to explicitly park an image on a second card to balance load or free VRAM on the first one; you're chaining a custom node that expects everything explicitly on cpu before it will accept input (some CPU-only preprocessing steps are like this); or you're debugging a device-mismatch error and want to force a known-good placement at a specific point in the graph rather than trace the mismatch back through everything upstream. If you're not hitting one of those situations, you almost certainly don't need this node - ComfyUI's default device handling is fine for the overwhelming majority of workflows, single-GPU or otherwise.
Installing it: this comes from comfyui-mask-util, a small utility pack by longgui0318, who's otherwise known for comfyui-magic-clothing - a virtual-try-on node that saw a short spike of Reddit interest in 2024 and hasn't come up since. Mask-util looks like the general glue split off from that project: device juggling, dtype juggling, crop math. There's no real README to speak of on the GitHub repo - just the project title - so nothing here is pulled from official documentation, it's read straight off the node's schema.
Install via ComfyUI Manager (search "comfyui-mask-util") or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-mask-util
Restart ComfyUI. No models to fetch and no extra dependencies - moving a tensor between devices is a single .to() call, as lightweight as custom nodes get.
Where it bites: picking cuda:1 (or any specific GPU index) when your machine only has one GPU, or doesn't have that index, will error out rather than silently fall back - check nvidia-smi for your actual device count before wiring in a specific index. Moving large images to cpu and back repeatedly adds real latency (PCIe transfer isn't free), so don't sprinkle this node through a hot loop expecting it to be invisible. And this only moves the tensor you plug into image - if a downstream error is about a model or a mask being on the wrong device instead, this node won't touch those; you'd want Mask Change Device or Model Change Device from the same pack for that.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| device | COMBO | 5 options: default, cpu, cuda, cuda:0, cuda:1 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |