开发者

YOLOv7 - RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

I have downloaded a custom dataset for YOLOv7 and I have cloned the YOLOv7 repository.

i want to do training with custom dataset for YOLOv7 with code like this

python train.py --workers 0 --batch-size 4 --device 0 --data data\face_mask.yaml --img 640 640 --cfg cfg\training\yolov7-face_mask.yaml --weights yolov7_training.pt --name yolov7-face-mask --hyp data\hyp.scratch.custom.yaml --epochs 300

at first it went well

YOLOR  30b3720 torch 1.13.0+cu117 CUDA:0 (NVIDIA GeForce R开发者_运维知识库TX 3050 Laptop GPU, 4095.5MB)

Namespace(weights='yolov7_training.pt', cfg='cfg\\training\\yolov7-face_mask.yaml', data='data\\face_mask.yaml', hyp='data\\hyp.scratch.custom.yaml', epochs=300, batch_size=4, img_size=[640, 640], rect=False, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket='', cache_images=False, image_weights=False, device='0', multi_scale=False, single_cls=False, adam=False, sync_bn=False, local_rank=-1, workers=0, project='runs/train', entity=None, name='yolov7-face-mask', exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias='latest', freeze=[0], v5_metric=False, world_size=1, global_rank=-1, save_dir='runs\\train\\yolov7-face-mask4', total_batch_size=4)
tensorboard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/
hyperparameters: lr0=0.01, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.3, cls_pw=1.0, obj=0.7, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.2, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, paste_in=0.0, loss_ota=1
wandb: Install Weights & Biases for YOLOR logging with 'pip install wandb' (recommended)
...

i got this RuntimeError

Epoch   gpu_mem       box       obj       cls     total    labels  img_size
  0%|                                                                          | 0/160 [00:08<?, ?it/s]
Traceback (most recent call last):
  File "C:\YOLOv7\yolov7-gpu\train.py", line 616, in <module>
    train(hyp, opt, device, tb_writer)
  File "C:\YOLOv7\yolov7-gpu\train.py", line 363, in train
    loss, loss_items = compute_loss_ota(pred, targets.to(device), imgs)  # loss scaled by batch_size
  File "C:\YOLOv7\yolov7-gpu\utils\loss.py", line 585, in __call__
    bs, as_, gjs, gis, targets, anchors = self.build_targets(p, targets, imgs)
  File "C:\YOLOv7\yolov7-gpu\utils\loss.py", line 759, in build_targets
    from_which_layer = from_which_layer[fg_mask_inboxes]
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Hardware :

  1. Acer Nitro 5
  2. Intel i5-11
  3. GPU Nivia RTX-3050

Software :

  1. Python 3.10
  2. Anaconda
  3. NVIDIA-SMI 517.48
  4. Driver Version: 517.48
  5. CUDA Version: 11.7

Please help and guidance, and explain the error. causes and solutions

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜