The gradient does not work through .cuda(). So instead of



 fxia22:

input = Variable(torch.rand(10,6), requires_grad = True).cuda()


use
input = Variable(torch.rand(10,6).cuda(), requires_grad = True).

Best regards
Thomas