The problem is that when you do x = x.cuda(), the new x is not the same as the old one.
If you do x_cuda = x.cuda(), then you can give x to the optimizer.
It is even better to send it to cuda before creating the Variable:
x = Variable(torch.FloatTensor(some_np_array).cuda(), requires_grad=True)
Hi, I met the same problem. Thanks for your tips.
I wonder what’s the difference between x and x_cuda?
Indeed, when our computing is processed in GPU, why dont we optimize x_cuda since it makes more sense?
Thanks.
@albanD I dnt understand why should give optimizer the x_cpu Instead of x_cuda??
Our computation is conducted on x_cuda, why not pass x_cuda to optimizer?