nanye commited on
Commit
033e505
·
1 Parent(s): d4ec601

further fix for zerogpu

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -18,9 +18,19 @@ from generate import CHECKPOINTS, ROOT, generate_images, load_model
18
  ZERO_GPU = os.environ.get("SPACES_ZERO_GPU", "").lower() in {"1", "true", "yes"}
19
  def gpu_unavailable(error):
20
  """Recognize allocation/quota/CUDA failures without masking model errors."""
21
- message = str(error).lower()
22
- return any(text in message for text in (
23
- "quota exceeded", "exceeded your gpu quota", "exceeded your zerogpu quota",
 
 
 
 
 
 
 
 
 
 
24
  "no gpu was available", "no gpu available", "cuda out of memory",
25
  "cuda is not available", "no nvidia driver", "not compiled with cuda",
26
  "cuda driver", "cuda-capable device", "gpu task aborted",
 
18
  ZERO_GPU = os.environ.get("SPACES_ZERO_GPU", "").lower() in {"1", "true", "yes"}
19
  def gpu_unavailable(error):
20
  """Recognize allocation/quota/CUDA failures without masking model errors."""
21
+ # Spaces puts the stable error category in gr.Error.title, while the
22
+ # message varies by authentication/subscription tier and quota type.
23
+ title = str(getattr(error, "title", "")).lower()
24
+ message = str(getattr(error, "message", str(error))).lower()
25
+ if title in {"zerogpu quota exceeded", "zerogpu pending credits exceeded"}:
26
+ return True
27
+ quota_failure = (
28
+ ("quota" in message and ("exceeded" in message or "exhausted" in message))
29
+ or "space app has reached its gpu limit" in message
30
+ or "exceeded your zerogpu runs limit" in message
31
+ or "too many zerogpu credits allocated" in message
32
+ )
33
+ return quota_failure or any(text in message for text in (
34
  "no gpu was available", "no gpu available", "cuda out of memory",
35
  "cuda is not available", "no nvidia driver", "not compiled with cuda",
36
  "cuda driver", "cuda-capable device", "gpu task aborted",