解决:RuntimeError: reflection_pad2d_backward_cuda does not have a deterministic implementation……

1. 场景:在改进yolov7过程中,出现的错误。

2. 错误描述:RuntimeError: reflection_pad2d_backward_cuda does not have a deterministic implementation, but you set ‘torch.use_deterministic_algorithms(True)’. You can turn off determinism just for this operation, or you can use the ‘warn_only=True’ option, if that’s acceptable for your application. You can also file an issue at https://github.com/pytorch/pytorch/issues to help us prioritize adding deterministic support for this operation.

3. 解决:找到torch.use_deterministic_algorithms()方法,将warn_only = False ,改为warn_only = True。

4. 原因:

        reflection_pad2d_backward_cuda没有确定性实现。设置PyTorch操作是否必须使用“确定性”算法。也就是说,在给定相同输入的情况下,当在相同的软件和硬件上运行时,算法总是产生相同的输出。启用后,操作将在可用时使用确定性算法,如果只有不确定性算法可用,则在调用时会抛出RuntimeError

        如果为 True,则使潜在的非确定性操作切换到确定性算法或引发运行时错误。如果为 False,则允许非确定性操作。

5. 警告:实际上这个设置对精度影响不大,影响精度在小数点后几位。如果不是对精度要求极高,其实不太建议修改,因为会使计算效率降低。确定性模式可能会对性能产生影响,具体取决于您的型号。

        

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年11月10日
下一篇 2023年11月10日

相关推荐