someone-in-the-world Claude Sonnet 4.6 commited on
Commit
5ed2ecb
·
1 Parent(s): 9acf075

Use cudaMallocAsync allocator to fix MIG GPU CUDACachingAllocator crash

Browse files

PyTorch's default CUDA Caching Allocator makes NVML memory queries
(nvmlDeviceGetMemoryInfo) that fail on MIG GPU instances running as
non-root, causing: NVML_SUCCESS == r INTERNAL ASSERT FAILED at
CUDACachingAllocator.cpp:1165. The cudaMallocAsync backend avoids
these NVML queries entirely.

Set via PYTORCH_CUDA_ALLOC_CONF at module level (before any CUDA init)
so it is inherited by ZeroGPU's subprocess.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -4,6 +4,9 @@ import time
4
  import threading
5
  import traceback
6
 
 
 
 
7
  import gradio as gr
8
  import numpy as np
9
  import spaces
 
4
  import threading
5
  import traceback
6
 
7
+ # cudaMallocAsync bypasses NVML memory queries that fail on MIG GPU instances
8
+ os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "backend:cudaMallocAsync")
9
+
10
  import gradio as gr
11
  import numpy as np
12
  import spaces