harp-dev commited on
Commit
02899a1
·
verified ·
1 Parent(s): 51d9480

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
@@ -65,7 +65,15 @@ def load_model():
65
  model_loading = False
66
 
67
 
68
- threading.Thread(target=load_model, daemon=True).start()
 
 
 
 
 
 
 
 
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(