harp-dev commited on
Commit
a67165c
·
verified ·
1 Parent(s): 1127500

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
@@ -127,7 +127,15 @@ def load_assets():
127
  model_loading = False
128
 
129
 
130
- threading.Thread(target=load_assets, daemon=True).start()
 
 
 
 
 
 
 
 
131
 
132
 
133
  model_card = ModelCard(
 
127
  model_loading = False
128
 
129
 
130
+ _loader = threading.Thread(target=load_assets, daemon=True)
131
+ _loader.start()
132
+
133
+ # pyharp's worker imports this file to reach process_fn (as __mp_main__ rather than
134
+ # __main__), so it finishes loading here, before process_fn can reserve a GPU, instead
135
+ # of racing the check there. The server itself keeps loading in the background, which
136
+ # lets it start at once.
137
+ if __name__ != "__main__":
138
+ _loader.join()
139
 
140
 
141
  model_card = ModelCard(