hello every one
there is a quastion when i use torch to optimize my simple model
it works when they are in   cpu(no .cuda())
when it moves to cuda  and it fails to compute
i hope someone help me to solve this
thanks in advance
N, D_in, H, D_out = 64, 1000, 100, 10

X = torch.randn(N,D_in).cuda()
Y = torch.randn(N,D_out).cuda()
W1 = torch.randn(D_in,H,requires_grad=True).cuda()
W2 = torch.randn(H, D_out,requires_grad=True).cuda()
learning_rate = 1e-6
for t in range(500):
#forward propagation
h = X.mm(W1) #N * H
h_relu = h.clamp(min=0)
y_pred = h_relu.mm(W2) #N * D_out
#loss function
loss = (y_pred-Y).pow(2).sum()
#print('y',Y)
#print('y pred',y_pred)
print(loss.item())
#backword propagation
loss.backward()
with torch.no_grad():
    
#update weights
    W1 -= learning_rate * W1.grad
    W2 -= learning_rate * W2.grad
    W1.grad.zero_()
    W2.grad.zero_()

===========================================
26         W1 -= learning_rate * W1.grad
27         W2 -= learning_rate * W2.grad
28         W1.grad.zero_()
TypeError: unsupported operand type(s) for *: ‘float’ and ‘NoneType’