WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

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

Closed lincit closed 1 year ago

lincit commented 1 year ago

When Starting training for epochs, a RuntimeError happened.

Using torch 1.13.1 CUDA:0 (NVIDIA GeForce GTX 1650, 4095MB) ... Epoch gpu_mem box obj cls total targets img_size 0%| | 0/8985 [00:05<?, ?it/s] Traceback (most recent call last): File "D:/browser/cgan/yolor/train.py", line 537, in train(hyp, opt, device, tb_writer, wandb) File "D:/browser/cgan/yolor/train.py", line 288, in train loss, loss_items = compute_loss(pred, targets.to(device), model) # loss scaled by batch_size File "D:\browser\cgan\yolor\utils\loss.py", line 66, in compute_loss tcls, tbox, indices, anchors = build_targets(p, targets, model) # targets File "D:\browser\cgan\yolor\utils\loss.py", line 149, in build_targets a, t = at[j], t.repeat(na, 1, 1)[j] # filter RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

Please help me

luonghuuthanhnam commented 1 year ago

Hello friend, I faced same issue and fixed it. checkout changes of this pull request #284

image