Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lincit opened this issue Dec 17, 2022 · 1 comment

Comments

@lincit
Copy link

lincit commented Dec 17, 2022

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
Copy link

luonghuuthanhnam commented Jan 6, 2023

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

image

@lincit lincit closed this as completed Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants