Closed JonasZero closed 3 years ago
try different loss. i don't think this is related to ASL. if different loss does work, give reproducible code
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [64, 38]] is at version 3; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
I use a single label classification dataset. The version of Pytorch I use is 1.7.1.
targets = copy.deepcopy(self.targets_classes)
The code above solve this.
provide full reproduction code
For me, the CrossEntropyLoss can work well, but when I change to use ASLSingleLabel it occurs same error. And targets = copy.deepcopy(self.targets_classes)
work for me.
i fixed the issue (it occurs on some models, on others it does not).
not recommended to do: targets = copy.deepcopy(self.targets_classes) which will cause you GPU memory leak along long training
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [64, 38]] is at version 3; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
I use a single label classification dataset. The version of Pytorch I use is 1.7.1.