As you said, I double checked data type of both model and input. The model need torch.cuda.FloatTensor, but the input is torch.cuda.DoubleTensor. And you are right, x.requires_grad_().to(device) is not work, x.to(device) is`t a inplace operation. Thanks for your help!