最近跑代码的时候遇到这个问题,真的是头疼了几天,现在问题终于解决了!!!
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.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
解决办法:
1、使用CPU跑,看具体的报错是什么!或者在代码中加入CUDA_LAUNCH_BLOCKING=1,查看具体报错!总之确定报错原因!!!
2、解决报错问题(我是由于index有误,导致报错。对于涉及到index的数据,一定要仔细检查index呀!!)
解决报错一定要有耐心,可以一句句代码运行查找!
3、报错解决,再使用GPU跑,就可以啦!