compute_typesをソートして出力を安定化、getBestComputeTypeのselected_typesを初期化してロジックを簡素化

This commit is contained in:
misyaguziya
2025-10-25 15:22:50 +09:00
parent a54538ee70
commit 73969c2fb6

View File

@@ -100,7 +100,7 @@ def getComputeDeviceList() -> List[Dict[str, Any]]:
"device": "cpu", "device": "cpu",
"device_index": 0, "device_index": 0,
"device_name": "cpu", "device_name": "cpu",
"compute_types": ["auto"] + list(get_supported_compute_types("cpu", 0)), "compute_types": ["auto"] + sorted(list(get_supported_compute_types("cpu", 0))),
} }
] ]
@@ -108,7 +108,7 @@ def getComputeDeviceList() -> List[Dict[str, Any]]:
if torch is not None and hasattr(torch, "cuda") and torch.cuda.is_available(): if torch is not None and hasattr(torch, "cuda") and torch.cuda.is_available():
for device_index in range(torch.cuda.device_count()): for device_index in range(torch.cuda.device_count()):
gpu_device_name = torch.cuda.get_device_name(device_index) gpu_device_name = torch.cuda.get_device_name(device_index)
gpu_compute_types = ["auto"] + list(get_supported_compute_types("cuda", device_index)) gpu_compute_types = ["auto"] + sorted(list(get_supported_compute_types("cuda", device_index)))
# デバイスごとの計算タイプの制限 # デバイスごとの計算タイプの制限
if "GTX" in gpu_device_name: if "GTX" in gpu_device_name:
@@ -157,12 +157,11 @@ def getBestComputeType(device: str, device_index: int) -> str:
} }
# デバイス名に基づいて優先タイプを選択 # デバイス名に基づいて優先タイプを選択
selected_types = preferred_types["default"]
for key in preferred_types: for key in preferred_types:
if key in device_name: if key in device_name:
selected_types = preferred_types[key] selected_types = preferred_types[key]
break break
else:
selected_types = preferred_types["default"]
# 利用可能な計算タイプを返す # 利用可能な計算タイプを返す
for compute_type in selected_types: for compute_type in selected_types: