报错信息
untimeError: 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.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
解决方法:
代码前面加入
import os
os.environ['CUDA_LAUNCH_BLOCKING'] = '1'
在此运行,会报具体的错误信息