Thanks~ I do some experiment:
For tensor, the code like this:
b=torch.tensor([1.0,2.0],requires_grad=True)

with torch.no_grad():
   b=b.cuda() #b.requires_grad will be false
   b.requires_grad=True

y=(b*b).sum()
y.backward()
b.grad #this will work

And for net, i can do this:
for name, param in net.named_parameters():
        with torch.no_grad(): #I find dropout this line not effect the result,why....
            exec(f'net.{name}=torch.nn.Parameter(net.{name}.cuda())') #this will work

The above code will work as expected. And  for net, what is the effect for with torch.no_grad()? Because i find without this line it still works as expected.
Thanks a lot!