mirror of
https://github.com/huggingface/accelerate.git
synced 2025-10-20 10:03:46 +08:00
fix: torch_npu import error (#3764)
This commit is contained in:
@ -414,7 +414,12 @@ def is_npu_available(check_device=False):
|
||||
if importlib.util.find_spec("torch_npu") is None:
|
||||
return False
|
||||
|
||||
import torch_npu # noqa: F401
|
||||
# NOTE: importing torch_npu may raise error in some envs
|
||||
# e.g. inside cpu-only container with torch_npu installed
|
||||
try:
|
||||
import torch_npu # noqa: F401
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if check_device:
|
||||
try:
|
||||
|
Reference in New Issue
Block a user