Spaces:
Running
Running
Finish loading in pyharp's worker before process_fn can reserve a GPU.
Browse files
app.py
CHANGED
|
@@ -65,7 +65,15 @@ def load_model():
|
|
| 65 |
model_loading = False
|
| 66 |
|
| 67 |
|
| 68 |
-
threading.Thread(target=load_model, daemon=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
model_card = ModelCard(
|
|
|
|
| 65 |
model_loading = False
|
| 66 |
|
| 67 |
|
| 68 |
+
_loader = threading.Thread(target=load_model, daemon=True)
|
| 69 |
+
_loader.start()
|
| 70 |
+
|
| 71 |
+
# pyharp's worker imports this file to reach process_fn (as __mp_main__ rather than
|
| 72 |
+
# __main__), so it finishes loading here, before process_fn can reserve a GPU, instead
|
| 73 |
+
# of racing the check there. The server itself keeps loading in the background, which
|
| 74 |
+
# lets it start at once.
|
| 75 |
+
if __name__ != "__main__":
|
| 76 |
+
_loader.join()
|
| 77 |
|
| 78 |
|
| 79 |
model_card = ModelCard(
|