Which version of pytorch are you using?
It will be great if you could give a short reproducible script.
This works for me. Does it work for you?
import torch
device = 'cuda'
x = torch.rand(5,5)
y = x.to(device)

import torch.nn as nn
net = nn.Linear(5,5)
net.to(device)
out = net(y)