harp-dev commited on
Commit
84dabfb
·
verified ·
1 Parent(s): 6b8a58c

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
@@ -110,7 +110,15 @@ def download_checkpoints():
110
  checkpoints_loading = False
111
 
112
 
113
- threading.Thread(target=download_checkpoints, daemon=True).start()
 
 
 
 
 
 
 
 
114
 
115
 
116
  model_card = ModelCard(
 
110
  checkpoints_loading = False
111
 
112
 
113
+ _loader = threading.Thread(target=download_checkpoints, daemon=True)
114
+ _loader.start()
115
+
116
+ # pyharp's worker imports this file to reach process_fn (as __mp_main__ rather than
117
+ # __main__), so it finishes loading here, before process_fn can reserve a GPU, instead
118
+ # of racing the check there. The server itself keeps loading in the background, which
119
+ # lets it start at once.
120
+ if __name__ != "__main__":
121
+ _loader.join()
122
 
123
 
124
  model_card = ModelCard(