The .cuda() operation is not in place so you need to store the returned GPU tensor. Like so:
inputs = inputs.cuda()
targets = targets.cuda()

Notice that this operation is in place for models: e.g., model.cuda() will work as expected, you don’t have to do model = model.cuda()