Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update is_mlu_available #1537

Merged
merged 3 commits into from
May 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion mmengine/device/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
except Exception:
IS_NPU_AVAILABLE = False

try:
import torch_mlu
IS_MLU_AVAILABLE = True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to

IS_MLU_AVAILABLE = torch.mlu.is_available()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

except Exception:
IS_MLU_AVAILABLE = False

try:
import torch_dipu # noqa: F401
IS_DIPU_AVAILABLE = True
Expand Down Expand Up @@ -64,7 +70,7 @@ def is_npu_available() -> bool:

def is_mlu_available() -> bool:
"""Returns True if Cambricon PyTorch and mlu devices exist."""
return hasattr(torch, 'is_mlu_available') and torch.is_mlu_available()
return IS_MLU_AVAILABLE


def is_mps_available() -> bool:
Expand Down