When I verify mps
support using a recommended Python script:
import torch
if torch.backends.mps.is_available():
mps_device = torch.device(“mps”)
x = torch.ones(1, device=mps_device)
print (x)
else:
print (“MPS device not found.”)
I get output the following output:
tensor([1.], device=‘mps:0’)
But when I use the same script in Jupyter notebook, I get:
AttributeError Traceback (most recent call last)
Input In [1], in <cell line: 2>()
1 import torch
----> 2 if torch.backends.mps.is_available():
3 mps_device = torch.device(“mps”)
4 x = torch.ones(1, device=mps_device)
AttributeError: module ‘torch.backends’ has no attribute ‘mps’