Daankular commited on
Commit
6ad1cf9
Β·
1 Parent(s): 0030bd6

Guard _install_cuda_packages() startup call against quota exhaustion

Browse files

If ZeroGPU quota is exhausted at startup, the @spaces.GPU decorator
throws β€” previously this crashed module import causing RUNTIME_ERROR.
Now wrapped in try/except so the app stays alive; CUDA extensions will
be unavailable but each GPU-decorated function handles that gracefully.

Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -210,7 +210,12 @@ def _install_cuda_packages():
210
  _CUDA_PKG_MARKER.touch()
211
  print("[startup] CUDA packages installed.")
212
 
213
- _install_cuda_packages()
 
 
 
 
 
214
  # ── Paths ─────────────────────────────────────────────────────────────────────
215
  HERE = Path(__file__).parent
216
  PIPELINE_DIR = HERE / "pipeline"
 
210
  _CUDA_PKG_MARKER.touch()
211
  print("[startup] CUDA packages installed.")
212
 
213
+ try:
214
+ _install_cuda_packages()
215
+ except Exception as _e:
216
+ # Quota exhaustion or GPU unavailable at startup β€” CUDA extensions may be missing,
217
+ # but don't crash the app. Each GPU-decorated function will handle missing imports.
218
+ print(f"[startup] WARNING: _install_cuda_packages failed ({type(_e).__name__}): {_e}")
219
  # ── Paths ─────────────────────────────────────────────────────────────────────
220
  HERE = Path(__file__).parent
221
  PIPELINE_DIR = HERE / "pipeline"