Pytorch中的錯誤和bug


RuntimeError:one of the variables needed for gradient computation has been modified by an inplace operation

原因:0.4.0把Varible和Tensor融合為一個Tensor,inplace操作,之前對Varible能用,但現在對Tensor,就會出錯了,所以找到模型中所有的inplace操作,換成非inplace的寫法就行

參考:https://blog.csdn.net/DuinoDu/article/details/80435127

RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/THCTensorCopy.cu:102

/pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:101: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [3,0,0] Assertion t >= 0 && t < n_classes failed.

原因:有可能是最后一層的layer的參數num_labels不對,導致GPU跑的時候出錯

參考:https://github.com/pytorch/pytorch/issues/10303

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM