Mask Change Device
Move a Mask Tensor to a Specific CPU or GPU
- mask
- mask
Masks are tensors just like images, which means they carry the same "which device am I actually sitting on" question - and the same annoying error when two things that need to interact aren't on the same one. Mask Change Device is exactly Image Change Device's counterpart, just scoped to masks instead of images: point it at a mask and a target device, and it relocates the tensor there.
Two inputs, nothing more: mask, whatever you're moving, and device, the familiar five-option dropdown shared across this whole pack - default (leave placement as-is), cpu, cuda, cuda:0, cuda:1. Output is mask, same content, new location. There's no transformation of the mask's values here, purely a device move.
You'll reach for this in the same handful of situations Image Change Device covers: explicitly balancing memory across multiple GPUs on a local multi-card setup, satisfying a custom node that insists on CPU-resident input before it'll run, or isolating and fixing a device-mismatch error at a specific point in your graph instead of tracing it back through everything that produced the mask. If your masks are coming from a segmentation or detection node and something downstream is throwing a device error, this is the node to insert right at the seam rather than reworking your whole pipeline's device handling.
Installing it: this comes from comfyui-mask-util, a small utility pack by longgui0318, whose more visible project is comfyui-magic-clothing - a virtual-try-on node wrapper that had a brief spike of Reddit interest in 2024 and hasn't come up in community discussion since. Mask-util looks like the general device/dtype/crop glue split out of building that, rather than something with its own following - which mostly matters here because there's genuinely no README beyond the project title, so nothing below is drawn from official docs.
Install through 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 involved - moving a mask tensor between devices is a single .to() call.
Where it bites: requesting cuda:1 (or any GPU index) that doesn't exist on your machine fails outright rather than gracefully falling back - check your actual GPU count first if you're not sure. Masks are generally much smaller than the images they're derived from, so the transfer cost here is usually a non-issue compared to moving a full image or a model, but if you're doing it inside a tight loop over a large mask batch it can still add up. And this node only moves the mask itself - if the error you're chasing is actually about the image or the model it's paired with being on the wrong device, you want Image Change Device or Model Change Device from the same pack instead, not this one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| device | COMBO | 5 options: default, cpu, cuda, cuda:0, cuda:1 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |