Skip to content

Studio: diffusion budgets against one GPU, so a multi-GPU host offloads to RAM instead of using the second card #8235

Closed

Description

@danielhanchen

Summary

On a multi-GPU host, image and video generation puts the model in system RAM and leaves most of the VRAM idle. Reported as roughly 70 GiB of RAM in use against about 1 GiB of VRAM on a box with two 24 GB cards.

This is not a leak and it is not multi-GPU specific in the way it looks. The diffusion path is single-GPU by construction, so it budgets against one card, decides a model that needs more than one card's worth cannot be resident, and picks CPU offload. Offload streams weights from system RAM, which is exactly the observed shape. The second card is never used at all.

Evidence

torch.cuda.mem_get_info() reports the current device only, and _cuda_memory in studio/backend/core/inference/diffusion_memory.py calls it with no ordinal. Measured on a real two-GPU host:

CUDA_VISIBLE_DEVICES=0,3   torch sees 2 device(s)
  cuda:0    178.35 GiB total
  cuda:1    178.35 GiB total
  ALL GPUs combined: 356.71 GiB

resolve_diffusion_device_target() -> device='cuda'          <- no ordinal, no second device
snapshot_device_memory()          -> total_mib=182633 (178.35 GiB)

planner sees 178.35 GiB of the 356.71 GiB actually present (50%)

Exactly one card, and the target device string carries no ordinal.

Corroborating: torch.cuda.device_count() appears in the llama.cpp path, the training worker and the hardware monitor, and nowhere in the diffusion or video inference stack. There is no device_map, no max_memory and no sharding in either loader.

So on 2 x 24 GB, a 41 GB bf16 checkpoint is judged against 24 GB, not 48 GB, offload is chosen, and RAM fills. Working as written; just not as a user with two cards expects.

What this needs

Either diffusion learns to shard across visible GPUs (device_map / max_memory across ordinals, with the memory planner budgeting the sum), or the interface stops implying otherwise. The monitor currently reads "VRAM (2 GPUs)" while showing one card's capacity, which reads as a bug even when offload is behaving correctly.

Not attempting a fix here: it lands in _plan_memory and the diffusion memory estimators, which are being changed under #8187 / #8188.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions