ct-tranchau commited on
Commit
81ef57e
·
verified ·
1 Parent(s): 39cc007

Diagnostics: test 60s vs 300s reservation

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -136,6 +136,20 @@ def _diag_alloc():
136
  return f"{torch.cuda.get_device_name(0)}, alloc ok, sum={float(x.sum())}"
137
 
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  @spaces.GPU(duration=60)
140
  def _diag_devices():
141
  import torch
@@ -176,7 +190,8 @@ def _diag_dino():
176
 
177
  def run_diagnostics():
178
  steps = [
179
- ("1. CUDA allocation", _diag_alloc),
 
180
  ("2. model devices", _diag_devices),
181
  ("3. Cellpose-SAM on GPU", _diag_cellpose),
182
  ("4. DINOv2 on GPU", _diag_dino),
@@ -187,9 +202,6 @@ def run_diagnostics():
187
  lines.append(f"PASS {name}: {fn()}")
188
  except Exception as e:
189
  lines.append(f"FAIL {name}: {type(e).__name__}: {e}")
190
- lines.append("")
191
- lines.append("^ this step is where it breaks.")
192
- break
193
  return "\n".join(lines)
194
 
195
 
 
136
  return f"{torch.cuda.get_device_name(0)}, alloc ok, sum={float(x.sum())}"
137
 
138
 
139
+ @spaces.GPU(duration=300)
140
+ def _diag_alloc_long():
141
+ """Same trivial work, maximum reservation.
142
+
143
+ Before running the task, ZeroGPU has to materialise every CUDA tensor this
144
+ process registered at startup - which here means the 1.15 GB Cellpose-SAM
145
+ checkpoint and the DINOv2 backbone. If that restore is what blows the
146
+ budget, a trivial allocation still fails at 60 s but passes at 300 s.
147
+ """
148
+ import torch
149
+ x = torch.zeros(2048, 2048, device="cuda")
150
+ return f"{torch.cuda.get_device_name(0)}, alloc ok at 300s, sum={float(x.sum())}"
151
+
152
+
153
  @spaces.GPU(duration=60)
154
  def _diag_devices():
155
  import torch
 
190
 
191
  def run_diagnostics():
192
  steps = [
193
+ ("1. CUDA allocation (60s)", _diag_alloc),
194
+ ("1b. CUDA allocation (300s)", _diag_alloc_long),
195
  ("2. model devices", _diag_devices),
196
  ("3. Cellpose-SAM on GPU", _diag_cellpose),
197
  ("4. DINOv2 on GPU", _diag_dino),
 
202
  lines.append(f"PASS {name}: {fn()}")
203
  except Exception as e:
204
  lines.append(f"FAIL {name}: {type(e).__name__}: {e}")
 
 
 
205
  return "\n".join(lines)
206
 
207