mirror of
https://github.com/facefusion/facefusion.git
synced 2026-10-14 01:20:51 +02:00
move detect_execution_devices to system.py
This commit is contained in:
1 parent
73a298cd97
commit
f2f09fc215
2 files changed
+79
-78
No files matched your search
@@ -127,79 +127,3 @@ def resolve_openvino_device_type(execution_device_id : int) -> str:
|
|||||||
if execution_device_id == 0:
|
if execution_device_id == 0:
|
||||||
return 'GPU'
|
return 'GPU'
|
||||||
return 'GPU.' + str(execution_device_id)
|
return 'GPU.' + str(execution_device_id)
|
||||||
|
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def detect_static_execution_devices() -> List[ExecutionDevice]:
|
|
||||||
return detect_execution_devices()
|
|
||||||
|
|
||||||
|
|
||||||
def detect_execution_devices() -> List[ExecutionDevice]:
|
|
||||||
execution_devices : List[ExecutionDevice] = []
|
|
||||||
|
|
||||||
try:
|
|
||||||
pynvml.nvmlInit()
|
|
||||||
device_count = pynvml.nvmlDeviceGetCount()
|
|
||||||
|
|
||||||
for device_id in range(device_count):
|
|
||||||
handle = pynvml.nvmlDeviceGetHandleByIndex(device_id)
|
|
||||||
|
|
||||||
execution_devices.append(
|
|
||||||
{
|
|
||||||
'driver_version': pynvml.nvmlSystemGetDriverVersion(),
|
|
||||||
'framework':
|
|
||||||
{
|
|
||||||
'name': 'CUDA',
|
|
||||||
'version': pynvml.nvmlSystemGetCudaDriverVersion()
|
|
||||||
},
|
|
||||||
'product':
|
|
||||||
{
|
|
||||||
'vendor': 'NVIDIA',
|
|
||||||
'name': pynvml.nvmlDeviceGetName(handle)
|
|
||||||
},
|
|
||||||
'video_memory':
|
|
||||||
{
|
|
||||||
'total':
|
|
||||||
{
|
|
||||||
'value': pynvml.nvmlDeviceGetMemoryInfo(handle).total // (1024 * 1024 * 1024),
|
|
||||||
'unit': 'GB'
|
|
||||||
},
|
|
||||||
'free':
|
|
||||||
{
|
|
||||||
'value': pynvml.nvmlDeviceGetMemoryInfo(handle).free // (1024 * 1024 * 1024),
|
|
||||||
'unit': 'GB'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'temperature':
|
|
||||||
{
|
|
||||||
'gpu':
|
|
||||||
{
|
|
||||||
'value': pynvml.nvmlDeviceGetTemperature(handle, pynvml.NVML_TEMPERATURE_GPU),
|
|
||||||
'unit': 'C'
|
|
||||||
},
|
|
||||||
'memory':
|
|
||||||
{
|
|
||||||
'value': 0,
|
|
||||||
'unit': '%'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'utilization':
|
|
||||||
{
|
|
||||||
'gpu':
|
|
||||||
{
|
|
||||||
'value': pynvml.nvmlDeviceGetUtilizationRates(handle).gpu,
|
|
||||||
'unit': '%'
|
|
||||||
},
|
|
||||||
'memory':
|
|
||||||
{
|
|
||||||
'value': pynvml.nvmlDeviceGetUtilizationRates(handle).memory,
|
|
||||||
'unit': '%'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
pynvml.nvmlShutdown()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return execution_devices
|
|
||||||
+79
-2
@@ -1,12 +1,13 @@
|
|||||||
import shutil
|
import shutil
|
||||||
|
from functools import lru_cache
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
|
import pynvml
|
||||||
|
|
||||||
from facefusion import state_manager
|
from facefusion import state_manager
|
||||||
from facefusion.execution import detect_execution_devices
|
from facefusion.types import DiskMetrics, ExecutionDevice, MemoryMetrics, Metrics, NetworkMetrics, ProcessorMetrics
|
||||||
from facefusion.types import DiskMetrics, MemoryMetrics, Metrics, NetworkMetrics, ProcessorMetrics
|
|
||||||
|
|
||||||
|
|
||||||
def get_metrics_set() -> Metrics:
|
def get_metrics_set() -> Metrics:
|
||||||
@@ -22,6 +23,82 @@ def get_metrics_set() -> Metrics:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache()
|
||||||
|
def detect_static_execution_devices() -> List[ExecutionDevice]:
|
||||||
|
return detect_execution_devices()
|
||||||
|
|
||||||
|
|
||||||
|
def detect_execution_devices() -> List[ExecutionDevice]:
|
||||||
|
execution_devices : List[ExecutionDevice] = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
pynvml.nvmlInit()
|
||||||
|
device_count = pynvml.nvmlDeviceGetCount()
|
||||||
|
|
||||||
|
for device_id in range(device_count):
|
||||||
|
handle = pynvml.nvmlDeviceGetHandleByIndex(device_id)
|
||||||
|
|
||||||
|
execution_devices.append(
|
||||||
|
{
|
||||||
|
'driver_version': pynvml.nvmlSystemGetDriverVersion(),
|
||||||
|
'framework':
|
||||||
|
{
|
||||||
|
'name': 'CUDA',
|
||||||
|
'version': pynvml.nvmlSystemGetCudaDriverVersion()
|
||||||
|
},
|
||||||
|
'product':
|
||||||
|
{
|
||||||
|
'vendor': 'NVIDIA',
|
||||||
|
'name': pynvml.nvmlDeviceGetName(handle)
|
||||||
|
},
|
||||||
|
'video_memory':
|
||||||
|
{
|
||||||
|
'total':
|
||||||
|
{
|
||||||
|
'value': pynvml.nvmlDeviceGetMemoryInfo(handle).total // (1024 * 1024 * 1024),
|
||||||
|
'unit': 'GB'
|
||||||
|
},
|
||||||
|
'free':
|
||||||
|
{
|
||||||
|
'value': pynvml.nvmlDeviceGetMemoryInfo(handle).free // (1024 * 1024 * 1024),
|
||||||
|
'unit': 'GB'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'temperature':
|
||||||
|
{
|
||||||
|
'gpu':
|
||||||
|
{
|
||||||
|
'value': pynvml.nvmlDeviceGetTemperature(handle, pynvml.NVML_TEMPERATURE_GPU),
|
||||||
|
'unit': 'C'
|
||||||
|
},
|
||||||
|
'memory':
|
||||||
|
{
|
||||||
|
'value': 0,
|
||||||
|
'unit': '%'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'utilization':
|
||||||
|
{
|
||||||
|
'gpu':
|
||||||
|
{
|
||||||
|
'value': pynvml.nvmlDeviceGetUtilizationRates(handle).gpu,
|
||||||
|
'unit': '%'
|
||||||
|
},
|
||||||
|
'memory':
|
||||||
|
{
|
||||||
|
'value': pynvml.nvmlDeviceGetUtilizationRates(handle).memory,
|
||||||
|
'unit': '%'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
pynvml.nvmlShutdown()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return execution_devices
|
||||||
|
|
||||||
|
|
||||||
def detect_disk_metrics(drive_paths : List[str]) -> List[DiskMetrics]:
|
def detect_disk_metrics(drive_paths : List[str]) -> List[DiskMetrics]:
|
||||||
disk_metrics : List[DiskMetrics] = []
|
disk_metrics : List[DiskMetrics] = []
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user