Error when moving tensor to mps

if torch.backends.mps.is_available():
device = torch.device(‘mps’)
else:
device = torch.device(‘cpu’)

seq.shape
torch.Size([40, 1, 360, 4])

seq
tensor([[[[ 3.0769, 3.0000, 0.0667, -0.7650],
[ 3.0769, 3.0000, 0.0667, -0.7650],
[ 3.0769, 3.0000, 0.0667, -0.7650],
…,
[ 3.0769, 3.0000, 0.0667, -0.7650],
[ 3.0769, 3.0000, 0.0667, -0.7650],
[ 3.0769, 3.0000, 0.0667, -0.7650]]],
[[[ 3.2903, 3.0000, 0.4254, -0.1959],
[ 3.2903, 3.0000, 0.4254, -0.1959],
[ 3.2903, 3.0000, 0.4254, -0.1959],
…,
[ 3.2903, 3.0000, 0.2461, -0.2670],
[ 3.2903, 3.0000, 0.2461, -0.2670],
[ 3.2903, 3.0000, 0.2461, -0.2670]]],
[[[ 4.2152, 3.0000, -1.0094, 1.0848],
[ 4.2152, 3.0000, -1.0094, 1.0848],
[ 4.2152, 3.0000, -1.0094, 1.0848],
…,
[ 3.7883, 3.0000, 0.2461, 0.7290],
[ 3.7883, 3.0000, 0.2461, 0.7290],
[ 3.7883, 3.0000, 0.2461, 0.7290]]],
…,
[[[ 3.7883, 3.0000, 0.0667, 0.6579],
[ 3.7883, 3.0000, 0.0667, 0.6579],
[ 3.7883, 3.0000, 0.0667, 0.6579],
…,
[ 3.7883, 3.0000, 0.0667, 0.6579],
[ 3.7883, 3.0000, 0.0667, 0.6579],
[ 3.7883, 3.0000, 0.0667, 0.6579]]],
[[[ 4.0729, 3.0000, -0.8300, 0.8713],
[ 4.0729, 3.0000, -0.8300, 0.8713],
[ 4.0729, 3.0000, -0.8300, 0.8713],
…,
[ 4.1441, 3.0000, -0.8300, 1.0136],
[ 4.1441, 3.0000, -0.8300, 1.0136],
[ 4.1441, 3.0000, -0.8300, 1.0136]]],
[[[ 3.2903, 3.0000, 1.5015, 0.2310],
[ 3.1480, 3.0000, 1.5015, -0.0536],
[ 3.1480, 3.0000, 1.5015, -0.0536],
…,
[ 3.1480, 3.0000, 1.5015, -0.0536],
[ 3.1480, 3.0000, 1.5015, -0.0536],
[ 3.1480, 3.0000, 1.5015, -0.0536]]]], dtype=torch.float64)

device
PyDev console: starting.
device(type=‘mps’)

seq.to(device)

the masseg I get:
python quit unexpectedly

with the following Error:

libc++abi: terminating with uncaught exception of type c10::TypeError: Trying to convert Double to the MPS backend but there is no mapping for it.
Exception raised from getMPSDataType at /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/native/mps/OperationUtils.mm:121 (most recent call first):
frame #0: at::native::mps::getMPSDataType(c10::ScalarType) + 180 (0x293701318 in libtorch_cpu.dylib)

Metal GPU doesn’t support float64. You need to make sure your dtype is float32.

1 Like