Files
ServerKit/backend/app/api/gpu.py
T
Juan DenisandClaude Opus 4.8 d58fdd7da7 feat(system): NVIDIA GPU monitoring
- GpuService shells out to nvidia-smi for per-GPU stats (utilization, VRAM +
  memory %, temperature, power, fan, driver) and GPU compute processes with
  best-effort PID->container resolution via cgroup. Coerces [N/A] to null and
  degrades to "no GPUs" when nvidia-smi is absent.
- GET /api/v1/gpu/ returns {available, gpus, processes}.
- 6 tests: row parse, N/A coercion, availability, no-GPU info, endpoint, auth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 10:08:58 -04:00

14 lines
426 B
Python

from flask import Blueprint, jsonify
from flask_jwt_extended import jwt_required
from app.services.gpu_service import GpuService
gpu_bp = Blueprint('gpu', __name__)
@gpu_bp.route('/', methods=['GET'])
@jwt_required()
def gpu_info():
"""Per-GPU stats (utilization, VRAM, temperature, power, fan, driver) plus
the GPU compute processes, with best-effort container resolution."""
return jsonify(GpuService.info())