Sorry  guys ,I’m  very  stupid  ,  I  read   the  basic   concept  again  ,and  found that   if   I  use  x= x.cuda(),then  x  will   become not  a  leaf  ,  backward()  will  not  keep  gradient  for  x  ,  so  I  should  add   x.retain_grad()   after  x=x.cuda() ,  and  then ,  x  will  get  a   grad  here.