@mytec: iter2.3 multithreading p1 done
This commit is contained in:
30
backend/app/api/routes/system.py
Normal file
30
backend/app/api/routes/system.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import multiprocessing as mp
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/info")
|
||||
async def get_system_info():
|
||||
"""Return system info: CPU cores, GPU availability, parallel support."""
|
||||
cpu_cores = mp.cpu_count() or 1
|
||||
|
||||
gpu_info = None
|
||||
try:
|
||||
import cupy as cp
|
||||
if cp.cuda.runtime.getDeviceCount() > 0:
|
||||
props = cp.cuda.runtime.getDeviceProperties(0)
|
||||
gpu_info = {
|
||||
"name": props["name"].decode(),
|
||||
"memory_mb": props["totalGlobalMem"] // (1024 * 1024),
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return {
|
||||
"cpu_cores": cpu_cores,
|
||||
"parallel_workers": min(cpu_cores, 14),
|
||||
"parallel_enabled": True,
|
||||
"gpu": gpu_info,
|
||||
"gpu_enabled": gpu_info is not None,
|
||||
}
|
||||
Reference in New Issue
Block a user