To Device (mtb)
Force an image or mask tensor onto CPU or GPU
- image
- mask
- images
- masks
Somewhere in a heavy multi-stage pipeline, you sometimes need to explicitly say "this tensor lives on the CPU now, not the GPU" - usually to free VRAM for the next stage, or because two custom nodes from different packs disagree about which device a tensor should be on and one of them throws a device-mismatch error. To Device is the explicit, manual override for that.
What it does
It's a straightforward device-move call wrapped as a node: take an image and/or mask tensor and send it to wherever you tell it. In the current build the device dropdown effectively offers cpu - so in practice this node is about deliberately parking a tensor in system RAM rather than choosing between multiple GPUs.
Inputs and outputs
device- where to send the tensor.ignore_errors- when on, a failed device move won't crash your queue; it'll just leave the tensor where it was rather than halting the run. Useful if you're using this node defensively across workflows that might run on different hardware setups.image/mask- both optional, wire in whichever (or both) you need moved.
Outputs: images and masks, the same tensors, now on the target device.
Why you'd actually need this
Two real scenarios. First, VRAM pressure: a big intermediate tensor you're not using for the next few nodes doesn't need to sit on the GPU burning memory - shuffle it to CPU, do your GPU-heavy work elsewhere in the graph, and reload it when you actually need it. Second, and more common in practice: a "tensors on different devices" crash where one custom node handed you a CPU tensor and the next one assumed GPU, or vice versa. That's a real, recurring class of friction in a custom-node ecosystem this large - different packs' authors make different assumptions about device placement, and when two packs meet at a shared connector, the mismatch surfaces as a runtime error rather than a graph-time warning. To Device lets you fix it explicitly instead of hunting for which pack is the culprit.
Installing it
ComfyUI Manager: search "MTB Nodes," install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb
then restart, and if the node's missing afterward, go into comfy_mtb and run pip install -r requirements.txt yourself.
Common issues
This node has no dependencies beyond torch, which ComfyUI already needs, so it's rarely the thing that fails to load on its own. The actual gotcha is conceptual: moving a tensor to CPU doesn't make everything downstream automatically CPU-friendly - if the very next node expects a GPU tensor and doesn't move it back itself, you'll just relocate the device-mismatch error one step down the graph instead of fixing it. Use this node right at the point where the mismatch actually happens, not preemptively everywhere, and turn on ignore_errors while you're debugging which connection is the actual problem.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| ignore_errors | BOOLEAN | false | — |
| device | COMBO | cpu | 1 options: cpu |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| masks | MASK | — |