Spaces:
Running on Zero
Running on Zero
log memory at the failing block instead of probing
Browse files
app.py
CHANGED
|
@@ -146,6 +146,13 @@ def log_worker_tracebacks():
|
|
| 146 |
return inner(self, *a, **k)
|
| 147 |
except Exception:
|
| 148 |
import traceback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
traceback.print_exc()
|
| 150 |
raise
|
| 151 |
setattr(cls, name, outer)
|
|
@@ -207,35 +214,6 @@ def write_mp4(frames):
|
|
| 207 |
return path
|
| 208 |
|
| 209 |
|
| 210 |
-
def _probe(tag):
|
| 211 |
-
"""How much VRAM is actually reachable inside the worker, and up to what size?
|
| 212 |
-
|
| 213 |
-
The allocation that aborts the run is only ~49 MB, so either something rejects
|
| 214 |
-
allocations regardless of size or the device has far less headroom than the
|
| 215 |
-
48 GB a ZeroGPU `large` slice is supposed to give.
|
| 216 |
-
"""
|
| 217 |
-
import threading
|
| 218 |
-
free, total = torch.cuda.mem_get_info()
|
| 219 |
-
got = []
|
| 220 |
-
|
| 221 |
-
def work():
|
| 222 |
-
for mb in (64, 256, 1024, 4096, 8192):
|
| 223 |
-
try:
|
| 224 |
-
x = torch.empty(mb * 1024 * 256, dtype=torch.float32, device="cuda")
|
| 225 |
-
del x
|
| 226 |
-
got.append(f"{mb}MB ok")
|
| 227 |
-
except Exception as e:
|
| 228 |
-
got.append(f"{mb}MB {type(e).__name__}: {str(e)[:90]}")
|
| 229 |
-
break
|
| 230 |
-
|
| 231 |
-
t = threading.Thread(target=work)
|
| 232 |
-
t.start()
|
| 233 |
-
t.join()
|
| 234 |
-
print(f"[probe:{tag}] free={free / 2**30:.1f}G total={total / 2**30:.1f}G "
|
| 235 |
-
f"allocated={torch.cuda.memory_allocated() / 2**30:.1f}G "
|
| 236 |
-
f"reserved={torch.cuda.memory_reserved() / 2**30:.1f}G | {got}", flush=True)
|
| 237 |
-
|
| 238 |
-
|
| 239 |
def _duration(world, steer_to, steer_at, seconds, seed, *args, **kwargs):
|
| 240 |
# Worst case is the whole clip generated at the slowest observed rate, plus the
|
| 241 |
# world decode at the start. Declared tight on purpose: ZeroGPU compares the
|
|
@@ -261,8 +239,6 @@ def run(world: str, steer_to: str, steer_at: float, seconds: float, seed: int):
|
|
| 261 |
steer_frame = int(float(steer_at) * FPS)
|
| 262 |
steer_idx = PROMPTS.get(steer_to) if steer_to and steer_to != NO_STEER else None
|
| 263 |
|
| 264 |
-
_probe("before-start")
|
| 265 |
-
|
| 266 |
t0 = time.perf_counter()
|
| 267 |
engine.start(world=WORLDS[world], seed=int(seed))
|
| 268 |
# Opening a world decodes all 81 of its pixel frames in one call, which is by far
|
|
@@ -272,7 +248,7 @@ def run(world: str, steer_to: str, steer_at: float, seconds: float, seed: int):
|
|
| 272 |
# PyTorch asks NVML which processes hold memory, NVML is not available there, and
|
| 273 |
# the run dies on an internal assert instead. Hand the cache back first.
|
| 274 |
torch.cuda.empty_cache()
|
| 275 |
-
|
| 276 |
frames, pending_steer, last_push = [], steer_idx is not None, 0.0
|
| 277 |
|
| 278 |
# The worker runs in a thread and reports failure by setting status.state rather
|
|
|
|
| 146 |
return inner(self, *a, **k)
|
| 147 |
except Exception:
|
| 148 |
import traceback
|
| 149 |
+
free, total = torch.cuda.mem_get_info()
|
| 150 |
+
print(f"[fail] {name}: allocated="
|
| 151 |
+
f"{torch.cuda.memory_allocated() / 2**30:.1f}G peak="
|
| 152 |
+
f"{torch.cuda.max_memory_allocated() / 2**30:.1f}G reserved="
|
| 153 |
+
f"{torch.cuda.memory_reserved() / 2**30:.1f}G "
|
| 154 |
+
f"device_free={free / 2**30:.1f}G/{total / 2**30:.1f}G",
|
| 155 |
+
flush=True)
|
| 156 |
traceback.print_exc()
|
| 157 |
raise
|
| 158 |
setattr(cls, name, outer)
|
|
|
|
| 214 |
return path
|
| 215 |
|
| 216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
def _duration(world, steer_to, steer_at, seconds, seed, *args, **kwargs):
|
| 218 |
# Worst case is the whole clip generated at the slowest observed rate, plus the
|
| 219 |
# world decode at the start. Declared tight on purpose: ZeroGPU compares the
|
|
|
|
| 239 |
steer_frame = int(float(steer_at) * FPS)
|
| 240 |
steer_idx = PROMPTS.get(steer_to) if steer_to and steer_to != NO_STEER else None
|
| 241 |
|
|
|
|
|
|
|
| 242 |
t0 = time.perf_counter()
|
| 243 |
engine.start(world=WORLDS[world], seed=int(seed))
|
| 244 |
# Opening a world decodes all 81 of its pixel frames in one call, which is by far
|
|
|
|
| 248 |
# PyTorch asks NVML which processes hold memory, NVML is not available there, and
|
| 249 |
# the run dies on an internal assert instead. Hand the cache back first.
|
| 250 |
torch.cuda.empty_cache()
|
| 251 |
+
torch.cuda.reset_peak_memory_stats()
|
| 252 |
frames, pending_steer, last_push = [], steer_idx is not None, 0.0
|
| 253 |
|
| 254 |
# The worker runs in a thread and reports failure by setting status.state rather
|