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

Add startup environment diagnostics (_log_env)

Browse files

Prints GPU name/VRAM/compute cap, CUDA version, cuDNN version, system
RAM, and key library versions (spaces, diffusers, transformers, gradio,
accelerate, peft, torchvision) at startup. Exceptions always print the
error message — no silent pass. This would have instantly identified
spaces==0.51.0 as the culprit during the July 17 outage.

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

Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -34,6 +34,33 @@ print("torch.__version__ =", torch.__version__, flush=True)
34
  print("Using device:", device, flush=True)
35
  print(f"CUDA device_count={torch.cuda.device_count()}, is_available={torch.cuda.is_available()}", flush=True)
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # TF32 matmul: ~10-15% free speedup on Ampere/Hopper (bfloat16 accumulation paths benefit too)
38
  torch.backends.cuda.matmul.allow_tf32 = True
39
  torch.backends.cudnn.allow_tf32 = True
 
34
  print("Using device:", device, flush=True)
35
  print(f"CUDA device_count={torch.cuda.device_count()}, is_available={torch.cuda.is_available()}", flush=True)
36
 
37
+
38
+ def _log_env():
39
+ import importlib.metadata as _meta
40
+ if torch.cuda.is_available():
41
+ p = torch.cuda.get_device_properties(0)
42
+ print(f"[env] GPU: {p.name}, VRAM={p.total_memory/1024**3:.1f}GB, cap={p.major}.{p.minor}", flush=True)
43
+ print(f"[env] CUDA (torch build): {torch.version.cuda}", flush=True)
44
+ print(f"[env] cuDNN: {torch.backends.cudnn.version()}", flush=True)
45
+ for pkg in ["spaces", "diffusers", "transformers", "gradio", "accelerate", "peft", "torchvision"]:
46
+ try:
47
+ print(f"[env] {pkg}=={_meta.version(pkg)}", flush=True)
48
+ except Exception as e:
49
+ print(f"[env] {pkg}==? ({e})", flush=True)
50
+ try:
51
+ mem = {}
52
+ with open("/proc/meminfo") as f:
53
+ for line in f:
54
+ k, v = line.split(":", 1)
55
+ mem[k.strip()] = v.strip()
56
+ total_gb = int(mem["MemTotal"].split()[0]) / 1024**2
57
+ avail_gb = int(mem["MemAvailable"].split()[0]) / 1024**2
58
+ print(f"[env] RAM: {total_gb:.0f}GB total, {avail_gb:.0f}GB available", flush=True)
59
+ except Exception as e:
60
+ print(f"[env] RAM: unavailable ({e})", flush=True)
61
+
62
+ _log_env()
63
+
64
  # TF32 matmul: ~10-15% free speedup on Ampere/Hopper (bfloat16 accumulation paths benefit too)
65
  torch.backends.cuda.matmul.allow_tf32 = True
66
  torch.backends.cudnn.allow_tf32 = True