Skip to content

fix: fall back to CUDA runtime mem_get_info when NVML memory info is unsupported (e.g. NVIDIA GB10) - #288

Draft
zbrad wants to merge 1 commit into
crystian:mainfrom
zbrad:vram-query-fallback
Draft

fix: fall back to CUDA runtime mem_get_info when NVML memory info is unsupported (e.g. NVIDIA GB10)#288
zbrad wants to merge 1 commit into
crystian:mainfrom
zbrad:vram-query-fallback

Conversation

@zbrad

@zbrad zbrad commented Aug 27, 2026

Copy link
Copy Markdown

Problem

On NVIDIA GB10 (a unified coherent-memory SoC — Grace Blackwell "DGX Spark"-class hardware, not a discrete VRAM card), pynvml.nvmlDeviceGetMemoryInfo() raises NVMLError_NotSupported. This happens even though NVML itself, GPU utilization, and temperature queries all work fine — it's specifically the memory counters that are unpopulated for this architecture.

Confirmed independently at the driver level: nvidia-smi -q -d MEMORY shows FB Memory Usage and BAR1 Memory Usage as N/A on this hardware (driver 580.173.02). Not a pynvml version gap either — there's no nvmlDeviceGetMemoryInfo_v2 in this pynvml build to fall back to.

Today, deviceGetMemoryInfo() just raises on the first call, which trips the except in getStatus() and sets switchVRAM = False — permanently disabling the VRAM panel for the whole session, with only a generic Could not get GPU memory info. Not Supported log line.

Fix

torch.cuda.mem_get_info() (the CUDA runtime API — a different driver subsystem from NVML) works fine on GB10 and reports real numbers against the same coherent memory pool. It's the same primitive ComfyUI's own model_management.py already relies on for VRAM accounting, so it's a reasonable fallback source here too.

Rather than hardcoding this by GPU name or architecture string, this adds a one-time runtime probe (probeMemoryInfoSource) per device at startup: try nvmlDeviceGetMemoryInfo, and only on NVMLError_NotSupported specifically, test torch.cuda.mem_get_info() against the same device index. Whichever source actually works gets cached per device index in self.gpusVRAMSource, and deviceGetMemoryInfo() dispatches off that cache on every subsequent poll.

This keeps existing behavior fully unchanged on discrete-VRAM GPUs (nvml path untouched), fixes it for GB10-class unified-memory SoCs (new torch fallback), and should keep working correctly for any future architecture/driver combination — including a machine with mixed GPU types, since the probe and its result are both per-device-index rather than global.

Testing

Verified live against a GB10 box running ComfyUI + this node as a systemd service. Startup log went from:

[Crystools ERROR] Could not get GPU memory info. Not Supported

to:

[Crystools WARNING] GPU 0: NVML memory info not supported by this driver/architecture, trying CUDA runtime fallback.
[Crystools INFO] GPU 0: using CUDA runtime memory info (torch.cuda.mem_get_info).

with the VRAM panel now reporting real numbers (cross-checked against /proc/meminfo) instead of staying disabled for the session. GPU utilization and temperature reporting are untouched by this change.

Opening as draft since I haven't exercised the actual crystools.monitor websocket message end-to-end in automated form — verified via the startup log's source-selection line and a direct call to the same torch.cuda.mem_get_info() path instead. Happy to add a lighter-weight test or tighten anything if useful.

nvmlDeviceGetMemoryInfo (and nvmlDeviceGetBAR1MemoryInfo) return
NVML_ERROR_NOT_SUPPORTED on NVIDIA GB10 (a unified coherent-memory SoC,
confirmed independently via nvidia-smi -q -d MEMORY showing all fields
N/A) even though NVML itself, utilization, and temperature queries all
work fine. Previously this made deviceGetMemoryInfo() raise on first
call, permanently disabling the VRAM panel for the whole session.

Add probeMemoryInfoSource(), run once per device at startup: try
nvmlDeviceGetMemoryInfo, and on NVMLError_NotSupported specifically,
fall back to testing torch.cuda.mem_get_info() (the CUDA runtime's own
query, already used by ComfyUI's own model_management.py for VRAM
accounting) against the same device index. Cache the winning source
per device index and dispatch off it on every subsequent call.

This is a runtime capability probe, not an arch/name check, so it
keeps working correctly on discrete-VRAM GPUs (nvml path, unchanged
behavior), on GB10-class unified-memory SoCs (torch fallback, new),
and on any future architecture/driver combination without needing a
code change -- including a mixed-GPU machine, since the probe and the
cached source are both per-device-index.

Assisted-by: Claude Sonnet 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant