RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR

笔者是跑Yolo-World的训练脚本train.py时报出这个错误的。神奇的是这个问题出现的起因是:
笔者跑train.py后报出显存不足的错误,随后将batchsize=16修改为batchsize=4。就报出了该错误:

# 这里只是截取了报错的关键最后一段
  File "/home/jin/anaconda3/envs/yoloworld/lib/python3.8/site-packages/torch/autograd/__init__.py", line 173, in backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR
You can try to repro this exception using the following code snippet. If that doesn't trigger the error, please include your original repro script when reporting this issue.

import torch
torch.backends.cuda.matmul.allow_tf32 = False
torch.backends.cudnn.benchmark = True
torch.backends.cudnn.deterministic = False
torch.backends.cudnn.allow_tf32 = True
data = torch.randn([4, 64, 20, 20], dtype=torch.float, device='cuda', requires_grad=True)
net = torch.nn.Conv2d(64, 64, kernel_size=[1, 1], padding=[0, 0], stride=[1, 1], dilation=[1, 1], groups=1)
net = net.cuda().float()
out = net(data)
out.backward(torch.randn_like(out))
torch.cuda.synchronize()

这段报错中说:“您可以尝试使用以下代码片段重现此异常。如果这不会触发错误,请在报告此问题时加入您的代码。”
然后我新建一个demo.py脚本并运行该段代码,没有报出任何错误。

有趣的是,既然是修改batchsize导致的错误,我就想着将batchsize=4再调小到batchsize=1,然后就成功运行训练脚本了。哈哈这报错提示不给力啊。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值