Thanks for your help. I’m using DataParallel. I removed “.cuda()” in “self.latest_input” statement, but It seems that “input.clone()”  copy the tensor on CPU as I get the following error.

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!