Files
ServerKit/backend/app/plugins/serverkit-gpu/gpu.py
T
Juan Denis 4e1b7da5f6 Add NVIDIA GPU monitor plugin (backend + manifests)
Introduce serverkit-gpu extension: backend plugin with GPU API and service (nvidia-smi based) providing per-GPU metrics and best-effort container resolution for GPU processes. Files added: backend/app/plugins/serverkit-gpu/{__init__.py,gpu.py,gpu_service.py,plugin.json}. Also update several frontend plugin.json files (including serverkit-gpu) to match manifest formatting (trailing newline adjustments). The GPU service degrades gracefully when nvidia-smi or Docker info is unavailable.
2026-07-09 08:47:28 -04:00

21 lines
722 B
Python

"""GPU Monitor API endpoints (serverkit-gpu extension).
Mounted under ``/api/v1/gpu`` via the manifest's ``entry_point`` + ``url_prefix``
(the same prefix the core route used, so the frontend is unchanged — decision D9).
Thin routing layer over :class:`GpuService`; read-only metrics, JWT-protected.
"""
from flask import Blueprint, jsonify
from flask_jwt_extended import jwt_required
from .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())