RuntimeError: “addmm_cuda“ not implemented for ‘Int‘

cuda不支持整数的矩阵乘法

如下所示:

import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)
a=torch.tensor([1,2,3],dtype=torch.int).to(device)
b=a.unsqueeze(dim=-1)@ a.unsqueeze(dim=0)
print(b)

结果

Traceback (most recent call last):
  File "____mytest.py", line 5, in
    b=a.unsqueeze(dim=-1)@ a.unsqueeze(dim=0)
RuntimeError: "addmm_cuda" not implemented for 'Int'
 


但是当改成CPU时

import torch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)
a=torch.tensor([1,2,3],dtype=torch.int)
b=a.unsqueeze(dim=-1)@ a.unsqueeze(dim=0)
print(b)

cuda
tensor([[1, 2, 3],
        [2, 4, 6],
        [3, 6, 9]], dtype=torch.int32)

你可能感兴趣的:(pytorch,Python编程,人工智能原理,深度学习,机器学习,python)