Spaces:
Sleeping
Sleeping
further fix for zerogpu
Browse files
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 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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",
|