GB10 (DGX Spark): GR context creation fails with NV_ERR_NO_MEMORY (kgrctxAllocMainCtxBuffer) whenever no free order-9 block exists, with 50+ GiB free

Offen
#1,561 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
c, linux

Rechercherichtung

Start with kgraphicsShouldForceMainCtxContiguity in src/nvidia/generated/g_kernel_graphics_nvoc.h and the allocation path in src/nvidia/src/kernel/gpu/gr/kernel_graphics_context.c around lines 1115–1186. Trace how the main context buffer reaches __get_free_pages and inspect the related allocation helpers. Done means context creation succeeds when memory is available but no order-9 block exists, or reports that contiguous memory is unavailable distinctly from general out-of-memory.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug
NVIDIA Open GPU Kernel Modules Version

580.178.04 (NVIDIA UNIX Open Kernel Module for aarch64, release build as shipped with DGX OS 7.6.0)

Please confirm this issue does not happen with the proprietary driver (of the same version). This issue tracker is only for bugs specific to the open kernel driver.
  • I confirm that this does not happen with the proprietary driver package.
Operating System and Version

Ubuntu 24.04.5 LTS (NVIDIA DGX OS 7.6.0)

Kernel Release

Linux 7.0.0-1019-nvidia #19~24.04.2-Ubuntu SMP PREEMPT_DYNAMIC aarch64 GNU/Linux (DGX OS kernel, not self-built), where it was first measured. It also reproduces on the newer DGX OS kernel 7.0.0-1025-nvidia with the same driver; the attached bundle is from a 7.0.0-1025 boot and contains 153 kgrctxAllocMainCtxBuffer failure lines.

Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.
  • I am running on a stable kernel release.
Hardware: GPU

GPU 0: NVIDIA GB10 (DGX Spark)

Describe the bug

Creating a GR context fails with NV_ERR_NO_MEMORY while 50+ GiB of system memory are free. The first CUDA call in a process then fails with "CUDA error: out of memory", and a graphics context fails the same way, for example headless Chromium. It happens with no other GPU client present. It depends only on whether the Normal zone holds a free order-9 (2 MiB) block at that instant.

Kernel log at each failure (four lines per failed context; about 3,100 such groups in one boot):

NVRM: nvCheckOkFailedNoLog: Check failed: Out of memory [NV_ERR_NO_MEMORY] (0x00000051) returned from kgrctxAllocMainCtxBuffer(pGpu, pKernelGraphicsContext, pKernelGraphics, pKernelChannel) @ kernel_graphics_context.c:1387
NVRM: nvCheckOkFailedNoLog: Check failed: Out of memory [NV_ERR_NO_MEMORY] (0x00000051) returned from kgrctxAllocCtxBuffers(pGpu, pKernelGraphicsObject->pKernelGraphicsContext, pKernelGraphics, pKernelGraphicsObject) @ kernel_graphics_object.c:215
NVRM: nvCheckOkFailedNoLog: Check failed: Out of memory [NV_ERR_NO_MEMORY] (0x00000051) returned from _memdescAllocInternal(pMemDesc) @ mem_desc.c:1359
NVRM: nvAssertOkFailedNoLog: Assertion failed: Out of memory [NV_ERR_NO_MEMORY] (0x00000051) returned from status @ kernel_graphics_context.c:1178

Mechanism, from the 580.178.04 source:

  1. kgraphicsShouldForceMainCtxContiguity returns NV_TRUE unconditionally (src/nvidia/generated/g_kernel_graphics_nvoc.h). So the main context buffer is always allocated physically contiguous (src/nvidia/src/kernel/gpu/gr/kernel_graphics_context.c, 1115-1186).
  2. On this system the buffer is 1,409,024 bytes, which rounds up to one order-9 block.
  3. It comes from ordinary Linux memory: memdescAlloc → osAllocPages → nv_alloc_pages (contiguous) → nv_alloc_contig_pages → __get_free_pages(GFP_KERNEL | __GFP_RETRY_MAYFAIL ..., 9).
  4. There is no pool and no non-contiguous fallback. When the buddy allocator cannot supply an order-9 block, the context fails.

On this unified-memory system, ordinary workloads routinely consume every free order-9 block in the Normal zone: KVM/QEMU guests and model loading using transparent huge pages, and the page cache. Total free memory stays high throughout.

To Reproduce
  • Preconditions: DGX Spark, driver 580.178.04, transparent_hugepage=madvise (the default). Fragment the Normal zone's free order-9 blocks; running a few KVM/QEMU guests reaches 0 within minutes. Confirm with the count of free order-9+ blocks in /proc/buddyinfo (Normal zone, columns 9 and up).

  • With that count at 0, run a process that only creates a context:

    import torch
    
    def free_order9_plus():
        for line in open("/proc/buddyinfo"):
            f = line.split()
            if f[3] == "Normal":
                return sum(int(n) for n in f[4 + 9:])
    
    print("free order>=9 blocks before:", free_order9_plus())
    try:
        torch.zeros(1, device="cuda")
        torch.cuda.synchronize()
        print("OK")
    except Exception as e:
        print("FAIL", type(e).__name__, str(e).splitlines()[0])
    
  • Observed, with no other GPU user in either run:

    • 0 free order-9+ blocks (8,219 free order-8 blocks), 53 GiB free: FAIL in 0.7 s, "CUDA error: out of memory", and the four NVRM lines above are logged.
    • 5,554 free order-9+ blocks, 73 GiB free: OK in 0.4 s, nothing logged.
  • The failure rate tracks huge-page users: about 1.5 failed contexts an hour with no KVM guest running, and about 255 an hour with four guests running.

  • Dropping caches and compacting (sync; echo 3 > /proc/sys/vm/drop_caches; echo 1 > /proc/sys/vm/compact_memory) restores free order-9 blocks: from 3 to 2,233 in one test.

Bug Incidence

Sometimes

nvidia-bug-report.log.gz

nvidia-bug-report.log.gz

More Info

Expected: a context is created whenever enough memory is free, or the driver reports that no contiguous block is available, rather than "out of memory".

Request:

  • pre-allocate or pool the main context buffer, or allow a non-contiguous fallback for it on GB10;
  • return an error that distinguishes "no contiguous block" from "out of memory".

The proprietary kernel module does not support Blackwell (GB10), so this cannot be compared with it. The open module is the only kernel driver for this GPU.

Workarounds in use: transparent_hugepage=never host-wide, or periodic compaction.

Workaround trial: with transparent huge pages set to never for 7 h 22 min (up to four VMs running), context creation failed 41 times (5.6 an hour, 32 of them in one 20-minute window), against about 255 an hour with four VMs before; the failures no longer followed the number of VMs, and each burst came while free 2 MiB blocks were at or near zero, so never greatly reduces the failure but does not remove it: fragmentation from other memory users still starves the 2 MiB allocation.

Related: #1358 (GB10, NV_ERR_NO_MEMORY under memory pressure, with a different symptom: a host wedge).

Vorherrschende Sprache
C
Sterne
17.7k
Forks
2k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus NVIDIA/open-gpu-kernel-modules

Alle Issues in NVIDIA/open-gpu-kernel-modules

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.