欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > RuntimeError: CUDA error: device-side assert triggered

RuntimeError: CUDA error: device-side assert triggered

2024/10/23 19:19:36 来源:https://blog.csdn.net/qq_39435411/article/details/140964305  浏览:    关键词:RuntimeError: CUDA error: device-side assert triggered

1. 报错信息:

block: [0,0,0], thread: [0,0,0] Assertion ^idx_dim >= 0 && idx_dim < index_size && "index out of bounds" failed
block: [0,0,0], thread: [0,0,0] Assertion ^idx_dim >= 0 && idx_dim < index_size && "index out of bounds" failed
block: [0,0,0], thread: [0,0,0] Assertion ^idx_dim >= 0 && idx_dim < index_size && "index out of bounds" failedRuntimeError: CUDA error: device-side assert triggered
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.

解决方法,主要看图片:

2. 报错信息

/pytorch/aten/src/ATen/native/cuda/Loss.cu:115: operator(): block: [0,0,0], thread: [0,0,0] Assertion `input_val >= zero && input_val <= one` failed.
/pytorch/aten/src/ATen/native/cuda/Loss.cu:115: operator(): block: [0,0,0], thread: [1,0,0] Assertion `input_val >= zero && input_val <= one` failed.
/pytorch/aten/src/ATen/native/cuda/Loss.cu:115: operator(): block: [0,0,0], thread: [2,0,0] Assertion `input_val >= zero && input_val <= one` failed.RuntimeError: CUDA error: device-side assert triggered
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.

解决方法,主要看图片:

这个报错主要有以下几种情况,排查一下自己的代码有无下面情况。

  • 出现nan值。

  • 预测值与标签长度不一致。

  • 预测值或标签不在[0,1]范围内。

经过打印变量值,我发现我的预测值出现了nan的情况,但是跑其它的数据好好的。于是我便怀疑是数据出了问题。便去排查了一遍数据,最终发现了有些数据不正常。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com