I was going through this post ([SOLVED] Make Sure That Pytorch Using GPU To Compute 79) and I had the question, what is the difference between these two pieces of code?
import torch.nn as nn
net = nn.Sequential(OrderedDict( [ ('fc1',nn.Linear(3,1)) ]) )
net.cuda()

vs
import torch
import torch.nn as nn

use_cuda = torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else "cpu")

net = nn.Sequential( OrderedDict([ ('fc1', nn.Linear(3,1)) ]) )
net.to(device)

vs
import torch
import torch.nn as nn

use_cuda = torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else "cpu")

net = nn.Sequential( OrderedDict([ ('fc1', nn.Linear(3,1)) ]) )
net = net.to(device)

which one is the recommended one? Which one is the one that is hardware agnostic (i.e. no matter type of gpu or even cpu).
is there some sort of internal flag I can check to see if things are properly placed in GPU?