본문 바로가기
잡다한 코딩이야기

[PyTorch] inplace operation error 해결

by 김예비석사 2023. 1. 20.

loss_glad.backward()  # calculate the gradients. <- backward 구하는 부분에서 에러가 남

 

RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [100, 40]] is at version 351; expected version 341 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!


다 필요없고, pytorch 1.4 버전으로 바꿔서 하면 실행됨.

1.5부터 나타나는 파이토치의 에러라는 의견이 많았고, 논문 저자에게 이메일로 사용하고 있는 버전을 물으니

2020년 기준 1.1 to 1.4 버전이었다고 함.

 

3년이면 상당히 최근인데도 이렇게 에러가 나는구나.. ㅠㅠ