diff --git a/app.py b/app.py
index 6c2d94b..182fb19 100644
--- a/app.py
+++ b/app.py
@@ -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()]
diff --git a/static/index.html b/static/index.html
index 158e229..db3e591 100644
--- a/static/index.html
+++ b/static/index.html
@@ -126,6 +126,13 @@
👥
+
+
+
+
测试完成后,在历史列表或详情里点「📤 发送到评测站」,一键把结果发布到模型评测网站(端口 16066)对应账号下。
diff --git a/static/js/app.js b/static/js/app.js
index 6a589d7..05ac47c 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -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 = "未探测到 GPU(nvidia-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);