RuntimeError: CUDA error: an illegal memory access was encountered

RuntimeError: CUDA error: an illegal memory access was encountered,第1张

问题描述
Traceback (most recent call last):
  File "/home/zyc/code/code/mypointcloudnet/pointnet/pointnet/loss.py", line 53, in 
    print(loss)
  File "/home/zyc/miniconda3/lib/python3.7/site-packages/torch/_tensor.py", line 305, in __repr__
    return torch._tensor_str._str(self)
  File "/home/zyc/miniconda3/lib/python3.7/site-packages/torch/_tensor_str.py", line 434, in _str
    return _str_intern(self)
  File "/home/zyc/miniconda3/lib/python3.7/site-packages/torch/_tensor_str.py", line 409, in _str_intern
    tensor_str = _tensor_str(self, indent)
  File "/home/zyc/miniconda3/lib/python3.7/site-packages/torch/_tensor_str.py", line 264, in _tensor_str
    formatter = _Formatter(get_summarized_data(self) if summarize else self)
  File "/home/zyc/miniconda3/lib/python3.7/site-packages/torch/_tensor_str.py", line 100, 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
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

代码块22

class chamfer_function(torch.autograd.Function):
    @staticmethod
    def forward(ctx, xyz1, xyz2):
        
        dist1, dist2, idx1, idx2 = chamfer.forward(xyz1, xyz2 )
        ctx.save_for_backward(xyz1, xyz2, idx1, idx2)

        return dist1, dist2

大概是 ,非法的tesor 进入到了cuda中

解决办法

大概原因是 我没有将要训练的数据放在tensor中,只需要调用 (data).cuda()将数据放在cuda中即可

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/789276.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存