Try GPU
Ask for GPU 0, get told 'cpu' instead — the failover node
- device_str
A device string is the kind of tiny thing that makes or breaks a workflow: your model has to end up on the same device as its tensors, or you get a mismatch error that means nothing to a beginner. Try GPU is the pack's one-line answer to "which device should I use?" - it checks whether the GPU at gpu_index exists, and if it does it returns cuda:<index>, otherwise it falls back to cpu. That's the entire d2l try_gpu(i) function, in a node, on purpose.
Its whole personality is the fallback. It never errors because your machine doesn't have the GPU you asked for; it just quietly hands you cpu and lets the workflow run (slowly, on CPU, but run). For the pack's learning demos - where you'd rather a small model train on CPU than crash - that behavior is exactly right. It's the difference between "why does nothing work" and "oh, I'm on CPU now," and for a teaching tool that difference is the whole lesson.
Inputs
Just one: gpu_index, an INT widget, default 0, range 0–16. Ask for the GPU you'd like; the node checks reality and reports back.
Output
One output, device_str, of type STRING. Either cuda:0 (or cuda:<whatever index you asked for>) or cpu. It's just text - the node doesn't move anything, it tells you what device you should be moving things to. In practice you read this value, then configure your model nodes with that device string, or just look at it to learn which of your GPUs is index 0.
Installing it
Part of ComfyDL. ComfyUI Manager, search "ComfyDL". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt
Restart ComfyUI. Pack-wide install is light - matplotlib only, no model files.
Gotchas
The honest caveat is that this node is informational: gpu_index maxes out at 16, so if you've somehow got GPU 17 it'll just fall back to cpu - fine for any realistic machine, and a quirk you'll never actually hit. The bigger conceptual thing to internalize is the asymmetry between this and Try All GPUs (its sibling, which returns every GPU at once as a comma-joined string): Try GPU answers "is my GPU there?", Try All GPUs answers "what do I have?". If you're building a workflow that should scale across multiple GPUs, you want the "all" version; if you're just making sure your first training loop runs at all, this is the one.
There's no real community signal for this pack yet - zero impressions, no threads - so don't expect a troubleshooting archive. But a node this simple (one torch.cuda.device_count() check) has little room to fail. The common beginner confusion is expecting it to place a model on the GPU; it doesn't, it just tells you the string. Read it, then use it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| gpu_index | INT | 00–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| device_str | STRING | — |