1-RuntimeError: CUDA error: misaligned address 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.

其他功能型代码检查没有问题的情况下,我是在4块GPU上训练,但是再怎么调都出现这个问题

原因:我的模型是分类模型,数据集的类别数目是65,也就是是奇数,而我训练中的代码GPU设置是:

因此,就会同时使用4块GPU,当类别数目是奇数时就会出现以上错误,因此将这部分代码改为:

即可解决以上问题。如果类别数目是偶数,不会出现同原因的这个问题。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐