笔者是跑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
,然后就成功运行训练脚本了。哈哈这报错提示不给力啊。