RuntimeError: CUDA error: device-side assert triggeredCUDA kernel errors might be asynchronously re

我在训练IDDPM时遇到了

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.

字面翻译:

运行时错误:CUDA错误:触发了设备端断言

CUDA内核错误可能会在其他一些API调用中异步报告,因此下面的stacktrace可能不正确。

对于调试,请考虑传递CUDA_LAUNCH_BLOCKING=1。

使用“TORCH_USE_CUDA_DSA”进行编译以启用设备端断言。

把gpu换成cpu一下就找到问题了。原来是我的nn.Embedding(1000,512),嵌入只能嵌入[0,999],但是我的t随机生成[1-1000],当随机到1000时就会报错。

RuntimeError: CUDA error: device-side assert triggeredCUDA kernel errors might be asynchronously re_第1张图片

 在嵌入时将t-1

 成功解决问题

你可能感兴趣的:(debug,python,人工智能,深度学习)