有时候写PyTorch代码的时候,会意外遇到如下的cuda报错:
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.
并且前面还有海量的(根本翻不完的)报错信息:
Assertion idx_dim >= 0 && idx_dim < index_size && "index out of bounds"
冗余的报错信息导致我们没办法定位到出错的代码段,这里