Shayan Darabi Claude Opus 5.5 commited on
Commit
18fb9b0
·
1 Parent(s): 912dd45

Make the Space start on ZeroGPU hardware

Browse files

Free accounts can only run Gradio Spaces on ZeroGPU, which requires at least
one @spaces.GPU function at startup. Add a never-called stub (no GPU quota
used) and drop the python_version pin so ZeroGPU picks its supported Python.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Files changed (2) hide show
  1. README.md +0 -1
  2. app.py +15 -0
README.md CHANGED
@@ -6,7 +6,6 @@ colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 5.25.2
8
  app_file: app.py
9
- python_version: "3.11"
10
  pinned: false
11
  hf_oauth: true
12
  # optional, default duration is 8 hours/480 minutes. Max duration is 30 days/43200 minutes.
 
6
  sdk: gradio
7
  sdk_version: 5.25.2
8
  app_file: app.py
 
9
  pinned: false
10
  hf_oauth: true
11
  # optional, default duration is 8 hours/480 minutes. Max duration is 30 days/43200 minutes.
app.py CHANGED
@@ -10,6 +10,21 @@ import pandas as pd
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  # --- Agent Definition ---
14
  # The real agent lives in agent.py (LangGraph ReAct loop) and tools.py.
15
  class BasicAgent:
 
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
+ # --- ZeroGPU compatibility ---
14
+ # Free HF accounts can only host Gradio Spaces on ZeroGPU hardware, which refuses
15
+ # to start unless at least one @spaces.GPU function exists. Our agent needs no GPU
16
+ # (all heavy lifting runs on OpenAI), so this stub is never called and uses no GPU
17
+ # quota. The `spaces` package only exists on HF, hence the try/except.
18
+ try:
19
+ import spaces
20
+
21
+ @spaces.GPU
22
+ def _zerogpu_stub():
23
+ return None
24
+ except ImportError:
25
+ pass
26
+
27
+
28
  # --- Agent Definition ---
29
  # The real agent lives in agent.py (LangGraph ReAct loop) and tools.py.
30
  class BasicAgent: