cazyundee commited on
Commit
677b59e
·
verified ·
1 Parent(s): 0329f82

Keep local model benchmarks CPU only

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -29,10 +29,8 @@ if hf_token:
29
  def _gpu_startup_touch():
30
  return "ok"
31
 
32
- try:
33
- _gpu_startup_touch()
34
- except Exception as e:
35
- print(f"Warning: ZeroGPU touch failed: {e}", flush=True)
36
 
37
 
38
  def _log(msg):
@@ -252,8 +250,10 @@ def _run_bench(model_filter=None):
252
  mp = hf_hub_download(repo_id=mi["repo"], filename=mi["file"], cache_dir=_BENCH_CACHE)
253
  env = os.environ.copy()
254
  env["LD_LIBRARY_PATH"] = os.path.dirname(cli)
 
 
255
  t0 = time.time()
256
- to = 300 if mi["size_gb"] <= 6 else 600
257
  command = [bench, "-m", mp, "-t", str(nt), "-ngl", "0", "-p", "32", "-n", "64", "-o", "json"]
258
  p = subprocess.run(command, capture_output=True, text=True, timeout=to, env=env)
259
  wt = time.time()-t0
@@ -265,7 +265,9 @@ def _run_bench(model_filter=None):
265
  row = parsed[0] if isinstance(parsed, list) and parsed else parsed
266
  r.update({"status":"success", "total_time_sec":round(wt,2), "prompt_tokens":32, "completion_tokens":64, "prompt_tokens_per_sec":row.get("avg_ts", 0), "generation_tokens_per_sec":row.get("avg_ts", 0), "raw":row})
267
  except subprocess.TimeoutExpired:
268
- raise RuntimeError(f"llama-bench timed out after {to}s")
 
 
269
  except Exception as e:
270
  r["error"] = str(e)
271
  results.append(r)
 
29
  def _gpu_startup_touch():
30
  return "ok"
31
 
32
+ # Keep the decorated symbol so ZeroGPU Spaces recognize the app, but do not call it.
33
+ # The Respite API and all CPU benchmarks must not consume GPU time.
 
 
34
 
35
 
36
  def _log(msg):
 
250
  mp = hf_hub_download(repo_id=mi["repo"], filename=mi["file"], cache_dir=_BENCH_CACHE)
251
  env = os.environ.copy()
252
  env["LD_LIBRARY_PATH"] = os.path.dirname(cli)
253
+ env["CUDA_VISIBLE_DEVICES"] = ""
254
+ env["GGML_CUDA"] = "0"
255
  t0 = time.time()
256
+ to = 90 if mi["size_gb"] <= 6 else 180
257
  command = [bench, "-m", mp, "-t", str(nt), "-ngl", "0", "-p", "32", "-n", "64", "-o", "json"]
258
  p = subprocess.run(command, capture_output=True, text=True, timeout=to, env=env)
259
  wt = time.time()-t0
 
265
  row = parsed[0] if isinstance(parsed, list) and parsed else parsed
266
  r.update({"status":"success", "total_time_sec":round(wt,2), "prompt_tokens":32, "completion_tokens":64, "prompt_tokens_per_sec":row.get("avg_ts", 0), "generation_tokens_per_sec":row.get("avg_ts", 0), "raw":row})
267
  except subprocess.TimeoutExpired:
268
+ r["error"] = f"llama-bench timed out after {to}s on CPU"
269
+ results.append(r)
270
+ continue
271
  except Exception as e:
272
  r["error"] = str(e)
273
  results.append(r)