Spaces:
Running on Zero
Running on Zero
Commit ·
86b2ecb
1
Parent(s): c625bd1
Add error handling for Zero GPU initialization and fallback to CPU mode; update Gradio version in requirements
Browse files- app.py +15 -4
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -33,6 +33,11 @@ try:
|
|
| 33 |
except ImportError:
|
| 34 |
SPACES_AVAILABLE = False
|
| 35 |
print("Running without Zero GPU support")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Keep-alive state
|
| 38 |
last_activity = datetime.datetime.now()
|
|
@@ -388,7 +393,12 @@ def score_and_create_matrix_all_singles_impl(sequence,mutation_range_start=None,
|
|
| 388 |
|
| 389 |
# Apply Zero GPU decorator if available
|
| 390 |
if SPACES_AVAILABLE:
|
| 391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
else:
|
| 393 |
score_and_create_matrix_all_singles = score_and_create_matrix_all_singles_impl
|
| 394 |
|
|
@@ -536,9 +546,10 @@ if __name__ == "__main__":
|
|
| 536 |
print("Note: Models will be downloaded on first use")
|
| 537 |
print("Zero GPU spaces may sleep after ~15 minutes of inactivity")
|
| 538 |
|
| 539 |
-
#
|
| 540 |
-
tranception_design.launch(
|
| 541 |
server_name="0.0.0.0",
|
| 542 |
server_port=7860,
|
| 543 |
-
show_error=True
|
|
|
|
| 544 |
)
|
|
|
|
| 33 |
except ImportError:
|
| 34 |
SPACES_AVAILABLE = False
|
| 35 |
print("Running without Zero GPU support")
|
| 36 |
+
except Exception as e:
|
| 37 |
+
# Catch any other initialization errors
|
| 38 |
+
SPACES_AVAILABLE = False
|
| 39 |
+
print(f"Zero GPU initialization warning: {e}")
|
| 40 |
+
print("Running without Zero GPU support")
|
| 41 |
|
| 42 |
# Keep-alive state
|
| 43 |
last_activity = datetime.datetime.now()
|
|
|
|
| 393 |
|
| 394 |
# Apply Zero GPU decorator if available
|
| 395 |
if SPACES_AVAILABLE:
|
| 396 |
+
try:
|
| 397 |
+
score_and_create_matrix_all_singles = spaces.GPU(duration=300)(score_and_create_matrix_all_singles_impl)
|
| 398 |
+
except Exception as e:
|
| 399 |
+
print(f"Warning: Could not apply Zero GPU decorator: {e}")
|
| 400 |
+
print("Falling back to CPU mode")
|
| 401 |
+
score_and_create_matrix_all_singles = score_and_create_matrix_all_singles_impl
|
| 402 |
else:
|
| 403 |
score_and_create_matrix_all_singles = score_and_create_matrix_all_singles_impl
|
| 404 |
|
|
|
|
| 546 |
print("Note: Models will be downloaded on first use")
|
| 547 |
print("Zero GPU spaces may sleep after ~15 minutes of inactivity")
|
| 548 |
|
| 549 |
+
# Launch with queue for proper Zero GPU support
|
| 550 |
+
tranception_design.queue(max_size=20).launch(
|
| 551 |
server_name="0.0.0.0",
|
| 552 |
server_port=7860,
|
| 553 |
+
show_error=True,
|
| 554 |
+
share=False
|
| 555 |
)
|
requirements.txt
CHANGED
|
@@ -10,7 +10,7 @@ tqdm
|
|
| 10 |
biopython>=1.78,<2.0.0
|
| 11 |
matplotlib
|
| 12 |
seaborn
|
| 13 |
-
gradio=
|
| 14 |
datasets==1.18.3
|
| 15 |
wandb==0.12.11
|
| 16 |
jax>=0.3.25
|
|
|
|
| 10 |
biopython>=1.78,<2.0.0
|
| 11 |
matplotlib
|
| 12 |
seaborn
|
| 13 |
+
gradio>=4.0.0,<5.0.0
|
| 14 |
datasets==1.18.3
|
| 15 |
wandb==0.12.11
|
| 16 |
jax>=0.3.25
|