yolov3算法运行错误:CUDA error: device-side assert triggered

用yolov3算法进行训练时报错如下:

File "B:/PyTorch/PyTorch-YOLOv3/train.py", line 107, in 
loss, outputs = model(imgs, targets)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "B:\PyTorch\PyTorch-YOLOv3\models.py", line 259, in forward
x, layer_loss = module[0](x, targets, img_dim)
File "D:\Program Files\Python368\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "B:\PyTorch\PyTorch-YOLOv3\models.py", line 188, in forward
ignore_thres=self.ignore_thres,
File "B:\PyTorch\PyTorch-YOLOv3\utils\utils.py", line 317, in build_targets
class_mask[b, best_n, gj, gi] = (pred_cls[b, best_n, gj, gi].argmax(-1) == target_labels).float()
RuntimeError: CUDA error: device-side assert triggered

解决:自己的标签格式和原有算法不一致,主要包含两个方面:

  1. 算法标签的输入格式为:x,y,w,h,并且是归一化格式
  2. 算法标签类别应该从0开始,我的标签类别是从1开始,共20类,把类别为20的改为0,之后错误解决

你可能感兴趣的:(yolov3算法运行错误:CUDA error: device-side assert triggered)