Kaggle: Your Machine Learning and Data Science Community
import torch
x = torch.ones(3,4)
y=torch.rand(3,4)
c = torch.cuda.is_available()
print(c)
result = torch.Tensor(3,4)
if torch.cuda.is_available():
x = x.cuda()
y = y.cuda()
result = result.cuda()
torch.add(x, y, out=result)
print(result)