Spaces:
Paused
Paused
| from fastapi import FastAPI | |
| import subprocess | |
| app = FastAPI(title="Workspace API") | |
| def root(): | |
| return {"message": "workspace api online"} | |
| def health(): | |
| return {"status": "ok"} | |
| 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)} | |