Nodes/comfyui-magic-clothing/Change Pipeline Dtype And Device
ComfyUI Node

Change Pipeline Dtype And Device

The boring node that stops Magic Clothing from OOMing

By longgui0318·Created 2 years ago·Updated 2 years ago· 82
Change Pipeline Dtype And Device
  • pipeline
  • PIPELINE
dtype
device

Change Pipeline Dtype And Device does exactly what the name says, and it's the most-visited node in this pack for a reason: Magic Clothing is heavy, and this is the knob that decides whether it runs in 6 GB of VRAM or dies in a pile of CUDA OOM errors.

This pack ships two ways to do virtual try-on. The headline path is the native ComfyUI one - Load Magic Clothing Model + Add Magic Clothing Attention - and then there's the "&MC" diffusers pipeline line, where you build a whole diffusers StableDiffusionPipeline object and run it like it's 2023 again. This node lives in that second line. You'll find it right after a loader in the chain:

Load Magic Clothing Pipeline → Change Pipeline Dtype And Device →
Diffusers Scheduler Loader &MC → Diffusers Model Makeup &MC →
Load Magic Clothing Adapter → RUN Magic Clothing Diffusers Model

What it actually does

Mechanically it's embarrassingly simple: it calls pipeline.to(device, dtype) on the whole pipeline object and then records the result on pipeline.device and pipeline.dtype so downstream nodes know what they're holding. But the devil is in the defaults. The "default" dtype maps to float32, not "whatever the model was loaded as." If you just wire this through without touching the dropdown, you're running the whole pipeline in fp32 and wondering why your GPU is crying. Pick float16 explicitly unless you have a reason not to.

The device options are default, cpu, cuda, cuda:0, cuda:1. "default" hands it to ComfyUI's own managed device selection, which is almost always what you want. The explicit cuda:0/cuda:1 entries exist for people who want to pin a multi-GPU box or force it to the secondary card while the base ComfyUI graph runs elsewhere.

Inputs and output

  • pipeline (PIPELINE) - the loaded pipeline object from the pack's pipeline loader.
  • dtype - default / float32 / float16 / bfloat16.
  • device - default / cpu / cuda / cuda:0 / cuda:1.

It returns the same PIPELINE, which you keep threading through the chain.

Installing the pack

ComfyUI Manager is the easy route - search "comfyui-magic-clothing" (the pack's marketplace name) and hit Install. Or clone it manually:

cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-oms-diffusion
# restart ComfyUI

The diffusers side of this pack imports diffusers and safetensors at module load, so make sure those are in your Python env - most ComfyUI installs already have them, but a bare venv won't. The model files come from HuggingFace's ShineChen1024/MagicClothing repo and go in ComfyUI/models/unet.

Where people get burned

Beyond the fp32 trap, the usual failure is VRAM: the diffusers line holds a generation UNet and a second reference UNet for the clothing, so fp16 is close to mandatory. bfloat16 works on most modern cards and is a fine middle ground. And if you set cpu because you're out of memory, be prepared to wait - a 25-step 768×576 try-on on CPU is a "go make coffee, then dinner" proposition.

One more honest warning, from the pack's own README: Magic Clothing has a low success rate and struggles with dense patterns, so even a perfectly-tuned pipeline wants rerolls. This node won't fix that. It'll just make sure the thing you're rerolling actually fits in memory.

Categorypipeline

Inputs (3)

NameTypeDefaultDescription
pipelinePIPELINE
dtypeCOMBO4 options: default, float32, float16, bfloat16
deviceCOMBO5 options: default, cpu, cuda, cuda:0, cuda:1

Outputs (1)

NameTypeDescription
PIPELINEPIPELINE