Just write model.cuda() is enough while you need to use variable = variable.cuda().
model.cuda() converts all parameters such as weights in model from Parameter(torch.Tensor) to Parameter(torch.cuda.Tensor). So if you do model.cuda(), you need to give Variable.cuda() as input. Now, model's output is cudaed, you don’t need to add .cuda() to loss.