mirror of
https://github.com/facefusion/facefusion.git
synced 2026-05-12 18:32:18 +02:00
use define_xxx for the type() factories
This commit is contained in:
@@ -22,7 +22,7 @@ def create_static_library() -> Optional[ctypes.CDLL]:
|
||||
return None
|
||||
|
||||
|
||||
def create_driver_info_configuration() -> ctypes.Structure:
|
||||
def define_driver_info() -> ctypes.Structure:
|
||||
return type('AMDSMI_DRIVER_INFO', (ctypes.Structure,),
|
||||
{
|
||||
'_pack_': 1,
|
||||
@@ -35,7 +35,7 @@ def create_driver_info_configuration() -> ctypes.Structure:
|
||||
})()
|
||||
|
||||
|
||||
def create_rocm_version_configuration() -> ctypes.Structure:
|
||||
def define_rocm_version() -> ctypes.Structure:
|
||||
return type('AMDSMI_VERSION', (ctypes.Structure,),
|
||||
{
|
||||
'_pack_': 1,
|
||||
@@ -49,7 +49,7 @@ def create_rocm_version_configuration() -> ctypes.Structure:
|
||||
})()
|
||||
|
||||
|
||||
def create_product_info_configuration() -> ctypes.Structure:
|
||||
def define_product_info() -> ctypes.Structure:
|
||||
return type('AMDSMI_ASIC_INFO', (ctypes.Structure,),
|
||||
{
|
||||
'_pack_': 1,
|
||||
@@ -72,7 +72,7 @@ def create_product_info_configuration() -> ctypes.Structure:
|
||||
})()
|
||||
|
||||
|
||||
def create_device_memory_configuration() -> ctypes.Structure:
|
||||
def define_device_memory() -> ctypes.Structure:
|
||||
return type('AMDSMI_VRAM_USAGE', (ctypes.Structure,),
|
||||
{
|
||||
'_pack_': 1,
|
||||
@@ -85,7 +85,7 @@ def create_device_memory_configuration() -> ctypes.Structure:
|
||||
})()
|
||||
|
||||
|
||||
def create_device_utilization_configuration() -> ctypes.Structure:
|
||||
def define_device_utilization() -> ctypes.Structure:
|
||||
return type('AMDSMI_ENGINE_USAGE', (ctypes.Structure,),
|
||||
{
|
||||
'_pack_': 1,
|
||||
|
||||
@@ -24,7 +24,7 @@ def create_static_library() -> Optional[ctypes.CDLL]:
|
||||
return None
|
||||
|
||||
|
||||
def create_memory_configuration() -> ctypes.Structure:
|
||||
def define_device_memory() -> ctypes.Structure:
|
||||
return type('NVML_MEMORY', (ctypes.Structure,),
|
||||
{
|
||||
'_fields_':
|
||||
@@ -36,7 +36,7 @@ def create_memory_configuration() -> ctypes.Structure:
|
||||
})()
|
||||
|
||||
|
||||
def create_utilization_configuration() -> ctypes.Structure:
|
||||
def define_device_utilization() -> ctypes.Structure:
|
||||
return type('NVML_UTILIZATION', (ctypes.Structure,),
|
||||
{
|
||||
'_fields_':
|
||||
|
||||
@@ -48,13 +48,13 @@ def detect_nvidia_graphic_devices() -> List[GraphicDevice]:
|
||||
device_name = ctypes.create_string_buffer(96)
|
||||
nvidia_ml_library.nvmlDeviceGetName(device_handle, device_name, 96)
|
||||
|
||||
device_memory = nvidia_ml_module.create_memory_configuration()
|
||||
device_memory = nvidia_ml_module.define_device_memory()
|
||||
nvidia_ml_library.nvmlDeviceGetMemoryInfo(device_handle, ctypes.byref(device_memory))
|
||||
|
||||
device_temperature = ctypes.c_uint()
|
||||
nvidia_ml_library.nvmlDeviceGetTemperature(device_handle, 0, ctypes.byref(device_temperature))
|
||||
|
||||
device_utilization = nvidia_ml_module.create_utilization_configuration()
|
||||
device_utilization = nvidia_ml_module.define_device_utilization()
|
||||
nvidia_ml_library.nvmlDeviceGetUtilizationRates(device_handle, ctypes.byref(device_utilization))
|
||||
|
||||
graphic_devices.append(
|
||||
@@ -123,23 +123,23 @@ def detect_amd_graphic_devices() -> List[GraphicDevice]:
|
||||
if amd_smi_library:
|
||||
amd_smi_library.amdsmi_init(ctypes.c_uint64(2))
|
||||
|
||||
rocm_version = amd_smi_module.create_rocm_version_configuration()
|
||||
rocm_version = amd_smi_module.define_rocm_version()
|
||||
amd_smi_library.amdsmi_get_lib_version(ctypes.byref(rocm_version))
|
||||
|
||||
for device_handle in amd_smi_module.find_device_handles(amd_smi_library):
|
||||
driver_info = amd_smi_module.create_driver_info_configuration()
|
||||
driver_info = amd_smi_module.define_driver_info()
|
||||
amd_smi_library.amdsmi_get_gpu_driver_info(device_handle, ctypes.byref(driver_info))
|
||||
|
||||
product_info = amd_smi_module.create_product_info_configuration()
|
||||
product_info = amd_smi_module.define_product_info()
|
||||
amd_smi_library.amdsmi_get_gpu_asic_info(device_handle, ctypes.byref(product_info))
|
||||
|
||||
device_memory = amd_smi_module.create_device_memory_configuration()
|
||||
device_memory = amd_smi_module.define_device_memory()
|
||||
amd_smi_library.amdsmi_get_gpu_vram_usage(device_handle, ctypes.byref(device_memory))
|
||||
|
||||
device_temperature = ctypes.c_int64()
|
||||
amd_smi_library.amdsmi_get_temp_metric(device_handle, 0, 0, ctypes.byref(device_temperature))
|
||||
|
||||
device_utilization = amd_smi_module.create_device_utilization_configuration()
|
||||
device_utilization = amd_smi_module.define_device_utilization()
|
||||
amd_smi_library.amdsmi_get_gpu_activity(device_handle, ctypes.byref(device_utilization))
|
||||
|
||||
graphic_devices.append(
|
||||
|
||||
Reference in New Issue
Block a user