Skip to content

Misc. bug: Intermittent CUDA error in launch_fattn on RTX 5080 Laptop (Blackwell SM 120) #22893

Closed

Description

@Scorp1o117

Description

On RTX 5080 Laptop GPU (Blackwell, compute capability 12.0), llama-server intermittently crashes at startup with a CUDA error in the Flash Attention kernel initialization. The error occurs probabilistically — sometimes the server starts successfully, sometimes it fails. Repeatedly retrying will eventually succeed.

The same error occurs with both upstream llama.cpp (main branch) and the TurboQuant fork, confirming this is not specific to any custom kernel modifications.

Games and 3DMark benchmarks run perfectly fine on this GPU, ruling out hardware defects.

Error Message

CUDA error: shared object initialization failed
  current device: 0, in function launch_fattn at .../fattn-common.cuh:1428
  cudaOccupancyMaxActiveBlocksPerMultiprocessor(&max_blocks_per_sm, fattn_kernel, block_dim.x * block_dim.y * block_dim.z, nbytes_shared)
llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu:100: CUDA error

Environment

  • GPU: NVIDIA GeForce RTX 5080 Laptop GPU (16GB VRAM, Blackwell, SM 120)
  • OS: Windows 11
  • Driver: 596.36
  • CUDA Toolkit: 13.2
  • llama.cpp: Both upstream main branch (prebuilt b9012) and TurboQuant fork (self-compiled with CMake + CUDA 13.2, CMAKE_CUDA_ARCHITECTURES=120)
  • Build config: -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=120

Steps to Reproduce

  1. Build llama.cpp with CUDA support targeting SM 120 (or use upstream prebuilt binaries)
  2. Run llama-server with any model and flash attention enabled (-fa on)
  3. Observe that startup sometimes succeeds and sometimes crashes with the error above
  4. Retry multiple times — the failure is probabilistic, not deterministic

Expected Behavior

llama-server should start reliably without intermittent CUDA kernel initialization failures.

Actual Behavior

Startup fails with roughly 30-50% probability (subjective estimate). When it fails, the error is always in launch_fattn at the cudaOccupancyMaxActiveBlocksPerMultiprocessor call. When it succeeds, the server runs normally with flash attention working correctly.

Additional Notes

  • The error is intermittent — the same binary, same model, same parameters can succeed on one launch and fail on the next
  • Disabling flash attention (-fa off) avoids the crash but loses FA performance benefits
  • The GPU passes all stress tests (gaming, 3DMark), suggesting this is a CUDA runtime/driver interaction issue rather than a hardware defect
  • The cudaOccupancyMaxActiveBlocksPerMultiprocessor API call returning cudaErrorSharedObjectInitFailed is unusual — this error code typically relates to shared library loading, not kernel occupancy calculation
  • On desktop RTX 5070 Ti (same CUDA toolkit, same driver family), the same builds work reliably
  • The laptop GPU has dynamic power management and may enter different power states, which could affect CUDA context initialization timing

Related

Activity

  1. Scorp1o117 commented on May 10, 2026

    @Scorp1o117
    Author

    Consolidated findings (replaces previous comments)

    Environment

    • GPU: RTX 5080 Laptop (16GB VRAM, Blackwell SM 120)
    • Driver: 596.36 | CUDA Toolkit: 13.2
    • OS: Windows 11
    • llama.cpp: Upstream prebuilt b9012 and self-compiled (CMake + CUDA 13.2, CMAKE_CUDA_ARCHITECTURES=120)
    • Same issue with TurboQuant fork — confirms this is upstream, not fork-specific
    • Games and 3DMark pass — rules out hardware defect

    Error

    Two different CUDA kernels fail with the same error code:

    # 1. Flash Attention (intermittent)
    CUDA error: shared object initialization failed
      current device: 0, in function launch_fattn at fattn-common.cuh:1428
      cudaOccupancyMaxActiveBlocksPerMultiprocessor(...)
    
    # 2. Matrix multiply during warmup (also intermittent)
    CUDA error: shared object initialization failed
      current device: 0, in function ggml_cuda_compute_forward at ggml-cuda.cu:2962
      ggml_cuda_compute_forward: MUL_MAT failed
    

    Reproduction pattern

    Model Architecture mmap --no-mmap
    Qwen3.5-9B Dense 9B 100% ✅ 100% ✅
    Qwen3.6-35B-A3B MoE 35B 100% ✅ ~70-80% fail ❌

    Key observations:

    1. MoE-specific — dense models never fail, only MoE models do
    2. --no-mmap specific — enabling mmap fixes it 100%, but mmap is impractical here (model file ~22GB + CPU-offloaded expert layers exhaust system RAM)
    3. Not FA-specific — both launch_fattn and plain MUL_MAT fail with the same error
    4. Intermittent — same binary, same model, same parameters succeed or fail randomly
    5. Desktop RTX 5070 Ti works fine with --no-mmap — this appears specific to Blackwell laptop GPUs

    Likely root cause

    The --no-mmap model loading path (direct read()/memcpy() instead of lazy page-faulting) interacts poorly with CUDA context initialization on Blackwell laptop GPUs. The different memory allocation timing may cause the CUDA runtime to dispatch kernels before the GPU context is fully ready, triggering cudaErrorSharedObjectInitFailed on the first kernel launch.

    Workaround

    --mmap (default) fixes stability, but causes excessive RAM usage with large MoE models on systems with limited RAM. A proper fix to the --no-mmap loading path is needed.

  2. Scorp1o117 commented on May 10, 2026

    @Scorp1o117
    Author

    Confirmed: Not Qwen3.6-35B specific — all MoE models affected

    Tested with Gemma 4 26B-A4B (different MoE architecture, different vendor) on the same RTX 5080 Laptop:

    Model Architecture mmap --no-mmap
    Qwen3.5-9B Dense 9B 100% ✅ 100% ✅
    Qwen3.6-35B-A3B MoE 35B 100% ✅ ~70-80% fail ❌
    Gemma 4 26B-A4B MoE 26B 100% ✅ Same failure ❌

    This confirms the bug is architecture-agnostic — it affects any MoE model loaded with --no-mmap on Blackwell laptop GPUs, not specific to Qwen3.6 or its MUL_MAT_ID implementation.

    The root cause is likely in the shared --no-mmap model loading path (read()/memcpy() into host RAM) rather than in any model-specific kernel code.

  3. added
    windows
    CUDA
    on May 10, 2026
  4. am17an commented on May 10, 2026

    @am17an
    Contributor

    You are probably running out of RAM on your computer, --no-mmap will force pinned memory which can cause OOM.

  5. Scorp1o117 commented on May 10, 2026

    @Scorp1o117
    Author

    Update: Same model, even less memory pressure on laptop — still fails

    I tested the exact same GGUF file (Qwen3.6-35B-A3B-uncensored-heretic-APEX-I-Quality.gguf, ~22GB) on both machines:

    Desktop (RTX 5070 Ti, 16GB VRAM, 32GB RAM) ✅

    • Command: -ncmoe23 --no-mmap -ngl 99 -fa on -c 131072
    • Result: Server starts successfully, listening on port 8088
    • VRAM usage: 14.2/16.0 GB

    Laptop (RTX 5080, 16GB VRAM, 32GB RAM) ❌

    • Command: -ncmoe23 --no-mmap -ngl 99 -fa on -c 64000 (smaller context!)
    • No mmproj file loaded (pure text model, no vision)
    • Result: CUDA error: shared object initialization failed at fattn-common.cu:1428
    • VRAM and RAM were not full at the time of failure

    Key observations

    1. Same model, same quantization, same --no-mmap flag — desktop works, laptop fails
    2. Laptop uses smaller context (64k vs 128k) and no vision encoder — should use less memory, not more
    3. VRAM and RAM were not exhausted when the error occurred
    4. This suggests the issue is not purely OOM — there may be a platform-specific difference in how CUDA context initialization interacts with the --no-mmap loading path on laptop Blackwell GPUs

    Screenshots attached below.


    Desktop (working): ![desktop]

    Image

    Laptop (failing): ![laptop]

    Image
  6. Scorp1o117 commented on May 10, 2026

    @Scorp1o117
    Author

    You are probably running out of RAM on your computer, --no-mmap will force pinned memory which can cause OOM.

    Please see my latest comment above with screenshots. The laptop actually uses less memory than the desktop:

    • Desktop: -c 131072 + mmproj loaded → works
    • Laptop: -c 64000 + no mmproj → fails

    Both have 32GB RAM. The laptop has lower memory pressure but still crashes. VRAM and RAM were not full at the time of failure.

    This makes me think it is not a simple OOM issue — something else is going on with how --no-mmap interacts with CUDA initialization on this specific laptop platform.

  7. Offset0x commented on May 13, 2026

    @Offset0x

    I have same issue on my windows desktop with RTX 5060 TI.
    ggml_cuda_compute_forward: MUL_MAT failed
    CUDA error: shared object initialization failed

    It is very random

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CUDAbug-unconfirmedwindows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions