Nodes/RES4LYF/Latent to Cuda
ComfyUI Node Runs on cloud

Latent to Cuda

Move a latent onto (or off) the GPU

By ClownsharkBatwing·Created 2 years ago·Updated 22 days ago· 1,222
Latent to Cuda
  • latent
  • LATENT
to_cudatrue
full_latenttrue

Latent to Cuda does exactly what the name says: it moves a latent tensor onto the GPU (CUDA), or leaves it where it is. That's the entire node. It's a plumbing fix, not a creative tool - the kind of thing you only ever wire in because something upstream put your latent on the wrong device and a later node is now complaining.

This is deep-in-the-weeds utility territory. Most people will never touch it, and that's fine. It exists because RES4LYF is a big pack that does a lot of unusual tensor gymnastics - high-precision fp64 math, custom samplers, style operations - and occasionally a latent ends up on the CPU when the next step wants it on the GPU, or vice versa. When that happens you get a "tensors on different devices" error, and this node is the one-line fix.

How it works

It takes a latent and pushes it to the CUDA device (or not, if you flip the toggle). There's a second switch for whether it moves the full latent dict or just the sample tensor inside it. No math, no transform to the values - just a device change.

The inputs and outputs that matter

  • latent (LATENT) - the latent to relocate.
  • to_cuda (default true) - on, it moves the latent to the GPU; off, it leaves it (useful if you specifically need it on CPU for a memory-sensitive step).
  • full_latent (optional, default true) - whether to move the whole latent structure or just its tensor payload.

Output is a single LATENT, now on the device you asked for, passed onward unchanged in content.

How to install it

Comes with RES4LYF. ComfyUI Manager: search RES4LYF, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

Portable builds use the embedded pip. Restart, hard-refresh (F5).

Common issues

If you're reading this because of a device-mismatch error, drop this node right before the step that's failing and set to_cuda true. That's usually the whole fix. The thing to not do is scatter these across a graph preemptively - a device move isn't free, and needing one at all is a sign of an upstream node behaving unusually, so it's worth noticing which node handed you a mis-placed latent. On a CPU-only ComfyUI install there's no CUDA device to move to, so this node has nothing to offer there. And it changes device, not content - if your image looks wrong, this isn't the node to blame; it doesn't touch the values.

CategoryRES4LYF/latents

Inputs (3)

NameTypeDefaultDescription
latentLATENT
to_cudaBOOLEANtrue
full_latentoptBOOLEANtrue

Outputs (1)

NameTypeDescription
LATENTLATENT