add another hasattr check for torch.backends.mps

This commit is contained in:
Jong Wook Kim 2023-01-18 14:44:02 -08:00 committed by GitHub
parent 4b77a81c1f
commit 51c785f7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,7 +94,7 @@ def load_model(name: str, device: Optional[Union[str, torch.device]] = None, dow
if device is None:
if torch.cuda.is_available():
device = "cuda"
elif torch.backends.mps.is_available():
elif hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
device = "mps"
else:
device = "cpu"