3 Commits
3 changed files with 46 additions and 1 deletions
+14
View File
@@ -2,6 +2,7 @@
"""LLM 速度测试台 - Flask 主应用"""
import io
import json
import subprocess
import requests
from flask import Flask, jsonify, request, send_file, send_from_directory
@@ -24,6 +25,19 @@ def index():
return send_from_directory(app.static_folder, "index.html")
@app.route("/api/gpu")
def gpu_info():
"""自动探测本机 GPU(nvidia-smi),供评测站同步时标注硬件"""
try:
out = subprocess.check_output(
["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"],
text=True, timeout=5, stderr=subprocess.DEVNULL)
gpus = [g.strip() for g in out.strip().splitlines() if g.strip()]
return jsonify({"ok": True, "gpus": gpus, "label": " / ".join(gpus)})
except Exception as e:
return jsonify({"ok": True, "gpus": [], "label": "", "error": str(e)})
@app.route("/api/health")
def health():
running = [tid for tid, r in RUNNERS.items() if r.is_alive()]
+7
View File
@@ -126,6 +126,13 @@
<label>评测站账号(结果挂到该账号下)</label>
<div class="icon-input"><span class="icon">👥</span><input id="eval-account" placeholder="如:性能评测组"></div>
</div>
<div class="field">
<label>硬件 / GPU(自动探测可修改,随结果一并发送)</label>
<div class="row">
<div class="icon-input"><span class="icon">🖥</span><input id="eval-hardware" placeholder="如:NVIDIA A100 80G"></div>
<button class="btn small" id="btn-detect-gpu" title="自动探测本机GPU">🔍 探测</button>
</div>
</div>
<button class="btn block" id="btn-eval-test">🔗 测试连接</button>
<div class="conn-result" id="eval-result" hidden></div>
<div class="hint" style="margin-top:6px">测试完成后,在历史列表或详情里点「📤 发送到评测站」,一键把结果发布到模型评测网站(端口 16066)对应账号下。</div>
+25 -1
View File
@@ -833,19 +833,41 @@ function evalSettings() {
return {
url: (localStorage.getItem("evalUrl") || "http://127.0.0.1:16066").replace(/\/+$/, ""),
account: localStorage.getItem("evalAccount") || "默认账号",
hardware: localStorage.getItem("evalHardware") || "",
};
}
function loadEvalSettings() {
const s = evalSettings();
const u = $("#eval-url"), a = $("#eval-account");
const u = $("#eval-url"), a = $("#eval-account"), h = $("#eval-hardware");
if (u) u.value = s.url;
if (a) a.value = s.account;
if (h) h.value = s.hardware;
}
function saveEvalSettings() {
localStorage.setItem("evalUrl", $("#eval-url").value.trim() || "http://127.0.0.1:16066");
localStorage.setItem("evalAccount", $("#eval-account").value.trim() || "默认账号");
localStorage.setItem("evalHardware", $("#eval-hardware").value.trim() || "");
}
async function detectGpu() {
const box = $("#eval-result");
try {
const r = await api("/api/gpu");
if (r.label) {
$("#eval-hardware").value = r.label;
saveEvalSettings();
box.hidden = false; box.className = "conn-result ok";
box.textContent = `✅ 已探测到 GPU${r.label}`;
} else {
box.hidden = false; box.className = "conn-result fail";
box.textContent = "未探测到 GPUnvidia-smi 不可用),可手动填写硬件描述";
}
} catch (e) {
box.hidden = false; box.className = "conn-result fail";
box.textContent = "❌ 探测失败:" + e.message;
}
}
async function testEvalConn() {
@@ -888,6 +910,7 @@ async function sendToEval(id) {
source_site: "llm-speed-tester",
provider: t.provider || "",
model: t.model || "",
hardware: s.hardware,
test_name: t.name || "",
summary: t.summary || {},
gen: t.gen || {},
@@ -951,6 +974,7 @@ function bind() {
$("#btn-test-conn").addEventListener("click", testConnection);
$("#btn-eval-test").addEventListener("click", testEvalConn);
$("#btn-detect-gpu").addEventListener("click", detectGpu);
$("#btn-start").addEventListener("click", startTest);
$("#btn-cancel").addEventListener("click", stopTest);
$("#btn-context-add").addEventListener("click", addContextLength);