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

 

posted @ 2018-09-23 22:12  sbj123456789  阅读(4414)  评论(0编辑  收藏  举报