RuntimeError: CUDA error: an illegal memory access was encountered

打印tensor数据出现如下错误:

    print(output)
  File "/home/qin/anaconda3/envs/Center/lib/python3.6/site-packages/torch/tensor.py", line 179, in __repr__
    return torch._tensor_str._str(self)
  File "/home/qin/anaconda3/envs/Center/lib/python3.6/site-packages/torch/_tensor_str.py", line 372, in _str
    return _str_intern(self)
  File "/home/qin/anaconda3/envs/Center/lib/python3.6/site-packages/torch/_tensor_str.py", line 352, in _str_intern
    tensor_str = _tensor_str(self, indent)
  File "/home/qin/anaconda3/envs/Center/lib/python3.6/site-packages/torch/_tensor_str.py", line 241, in _tensor_str
    formatter = _Formatter(get_summarized_data(self) if summarize else self)
  File "/home/qin/anaconda3/envs/Center/lib/python3.6/site-packages/torch/_tensor_str.py", line 89, in __init__
    nonzero_finite_vals = torch.masked_select(tensor_view, torch.isfinite(tensor_view) & tensor_view.ne(0))
RuntimeError: CUDA error: an illegal memory access was encountered
terminate called after throwing an instance of 'c10::Error'

代码如下:

for layer in self.layers:
    output = layer(output, pos, reference_points, spatial_shapes, padding_mask)

六层encoder,第五层的output打印出错
原因:
output第五层变成了0

https://discuss.pytorch.org/t/runtimeerror-cuda-error-an-illegal-memory-access-was-encountered-autograd/85282/9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值