mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-03 18:46:47 +09:00
- 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>
14 lines
426 B
Python
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())
|