Spaces:
Running on Zero
Running on Zero
Serialize CPU benchmark requests
Browse files
app.py
CHANGED
|
@@ -201,6 +201,7 @@ _BENCH_MODELS = [
|
|
| 201 |
]
|
| 202 |
_BENCH_CACHE = os.path.join(tempfile.gettempdir(), "llm_bench")
|
| 203 |
_BENCH_RESULTS = []
|
|
|
|
| 204 |
|
| 205 |
|
| 206 |
def _ensure_llama():
|
|
@@ -232,6 +233,11 @@ def _ensure_llama():
|
|
| 232 |
|
| 233 |
|
| 234 |
def _run_bench(model_filter=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
global _BENCH_RESULTS
|
| 236 |
if _BENCH_RESULTS and not model_filter: return _BENCH_RESULTS
|
| 237 |
import subprocess, re
|
|
@@ -254,7 +260,8 @@ def _run_bench(model_filter=None):
|
|
| 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
|
| 260 |
diagnostics = (p.stderr or "").strip()
|
|
|
|
| 201 |
]
|
| 202 |
_BENCH_CACHE = os.path.join(tempfile.gettempdir(), "llm_bench")
|
| 203 |
_BENCH_RESULTS = []
|
| 204 |
+
_BENCH_LOCK = threading.Lock()
|
| 205 |
|
| 206 |
|
| 207 |
def _ensure_llama():
|
|
|
|
| 233 |
|
| 234 |
|
| 235 |
def _run_bench(model_filter=None):
|
| 236 |
+
with _BENCH_LOCK:
|
| 237 |
+
return _run_bench_locked(model_filter)
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def _run_bench_locked(model_filter=None):
|
| 241 |
global _BENCH_RESULTS
|
| 242 |
if _BENCH_RESULTS and not model_filter: return _BENCH_RESULTS
|
| 243 |
import subprocess, re
|
|
|
|
| 260 |
env["GGML_CUDA"] = "0"
|
| 261 |
t0 = time.time()
|
| 262 |
to = 90 if mi["size_gb"] <= 6 else 180
|
| 263 |
+
command = [bench, "-m", mp, "-t", str(nt), "-ngl", "0", "-p", "32", "-n", "64", "-r", "1", "-o", "json"]
|
| 264 |
+
_log(f"Running llama-bench for {mi['name']} on CPU with {nt} threads")
|
| 265 |
p = subprocess.run(command, capture_output=True, text=True, timeout=to, env=env)
|
| 266 |
wt = time.time()-t0
|
| 267 |
diagnostics = (p.stderr or "").strip()
|