harp-dev commited on
Commit
72ad407
·
verified ·
1 Parent(s): 889a592

Finish loading in pyharp's worker before process_fn can reserve a GPU.

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -74,7 +74,15 @@ def download_beat_checkpoint():
74
  beat_checkpoint_ready.set()
75
 
76
 
77
- threading.Thread(target=download_beat_checkpoint, daemon=True).start()
 
 
 
 
 
 
 
 
78
 
79
 
80
  model_card = ModelCard(
 
74
  beat_checkpoint_ready.set()
75
 
76
 
77
+ _loader = threading.Thread(target=download_beat_checkpoint, daemon=True)
78
+ _loader.start()
79
+
80
+ # pyharp's worker imports this file to reach process_fn (as __mp_main__ rather than
81
+ # __main__), so it finishes loading here, before process_fn can reserve a GPU, instead
82
+ # of racing the check there. The server itself keeps loading in the background, which
83
+ # lets it start at once.
84
+ if __name__ != "__main__":
85
+ _loader.join()
86
 
87
 
88
  model_card = ModelCard(