WatNeru commited on
Commit
eefa01f
·
1 Parent(s): 8620bbf

Add startup event to request GPU for ZeroGPU detection

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -198,6 +198,17 @@ app = FastAPI(
198
  )
199
 
200
 
 
 
 
 
 
 
 
 
 
 
 
201
  @app.get("/")
202
  def root() -> Dict[str, str]:
203
  """簡易案内"""
 
198
  )
199
 
200
 
201
+ @app.on_event("startup")
202
+ async def startup_event():
203
+ """アプリ起動時の処理(ZeroGPU要求)"""
204
+ if SPACES_AVAILABLE:
205
+ try:
206
+ spaces.GPU()
207
+ print("[SPACE] GPU要求をstartup eventで送信しました")
208
+ except Exception as e:
209
+ print(f"[SPACE] GPU要求エラー: {e}")
210
+
211
+
212
  @app.get("/")
213
  def root() -> Dict[str, str]:
214
  """簡易案内"""