Unverified Commit 6840a7bb authored by JieXin Liang's avatar JieXin Liang Committed by GitHub
Browse files

[fix] put cpu in the first priority in get_device() (#7752)

parent c01a1df5
......@@ -1443,6 +1443,15 @@ def is_habana_available() -> bool:
@lru_cache(maxsize=8)
def get_device(device_id: Optional[int] = None) -> str:
if is_cpu():
if cpu_has_amx_support():
logger.info("Intel AMX is detected, using CPU with Intel AMX support.")
else:
logger.warning(
"CPU device enabled, using torch native backend, low performance expected."
)
return "cpu"
if hasattr(torch, "cuda") and torch.cuda.is_available():
if device_id is None:
return "cuda"
......@@ -1471,15 +1480,6 @@ def get_device(device_id: Optional[int] = None) -> str:
"Habana frameworks detected, but failed to import 'habana_frameworks.torch.hpu'."
)
if is_cpu():
if cpu_has_amx_support():
logger.info("Intel AMX is detected, using CPU with Intel AMX support.")
else:
logger.warning(
"CPU device enabled, using torch native backend, low performance expected."
)
return "cpu"
raise RuntimeError("No accelerator (CUDA, XPU, HPU) is available.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment