Spaces:
Paused
Paused
File size: 707 Bytes
7947b92 d519028 7947b92 d519028 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | from fastapi import FastAPI
import subprocess
app = FastAPI(title="Workspace API")
@app.get("/")
def root():
return {"message": "workspace api online"}
@app.get("/health")
def health():
return {"status": "ok"}
@app.get("/gpu")
def gpu_info():
try:
out = subprocess.check_output(
[
"nvidia-smi",
"--query-gpu=name,memory.total,driver_version",
"--format=csv,noheader",
],
text=True,
timeout=5,
)
gpus = [line.strip() for line in out.splitlines() if line.strip()]
return {"gpus": gpus}
except Exception as exc:
return {"gpus": [], "error": str(exc)}
|