@mytec: iter3.5.0 ready for testing
This commit is contained in:
35
backend/app/api/routes/gpu.py
Normal file
35
backend/app/api/routes/gpu.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""GPU management API endpoints."""
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.services.gpu_backend import gpu_manager
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
class SetDeviceRequest(BaseModel):
|
||||
backend: str
|
||||
index: int = 0
|
||||
|
||||
|
||||
@router.get("/status")
|
||||
async def gpu_status():
|
||||
"""Return GPU manager status: active backend, device, available devices."""
|
||||
return gpu_manager.get_status()
|
||||
|
||||
|
||||
@router.get("/devices")
|
||||
async def gpu_devices():
|
||||
"""Return list of available compute devices."""
|
||||
return {"devices": gpu_manager.get_devices()}
|
||||
|
||||
|
||||
@router.post("/set")
|
||||
async def gpu_set_device(request: SetDeviceRequest):
|
||||
"""Switch active compute device."""
|
||||
try:
|
||||
result = gpu_manager.set_device(request.backend, request.index)
|
||||
return {"status": "ok", **result}
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
Reference in New Issue
Block a user