Open hamdimina opened 1 year ago
This worked for me
Changing line 685 in utils/loss.py to:
from_which_layer.append((torch.ones(size=(len(b),)) * i).to('cuda'))
and adding a new line after 756
fg_mask_inboxes = fg_mask_inboxes.to(torch.device('cuda'))
This worked for me and also to most people
Changing line 685 in utils/loss.py to:
from_which_layer.append(torch.ones(size=(len(b), ), device=targets.device) * i)
and that's it.
I have also faced the same error in Colab for training with W6 weight file-
But changing the above-mentioned could not solve the error.
This worked for me and also to most people
Changing line 685 in utils/loss.py to:
from_which_layer.append(torch.ones(size=(len(b), ), device=targets.device) * i)
and that's it.
can you please provide how to put the command and change the line, cause i'm new in this domain and my knowledge are not wide and thanks
This worked for me and also to most people Changing line 685 in utils/loss.py to:
from_which_layer.append(torch.ones(size=(len(b), ), device=targets.device) * i)
and that's it.can you please provide how to put the command and change the line, cause i'm new in this domain and my knowledge are not wide and thanks
you work in google colab?
This worked for me and also to most people Changing line 685 in utils/loss.py to:
from_which_layer.append(torch.ones(size=(len(b), ), device=targets.device) * i)
and that's it.can you please provide how to put the command and change the line, cause i'm new in this domain and my knowledge are not wide and thanks
you work in google colab?
yes
This worked for me and also to most people Changing line 685 in utils/loss.py to:
from_which_layer.append(torch.ones(size=(len(b), ), device=targets.device) * i)
and that's it.can you please provide how to put the command and change the line, cause i'm new in this domain and my knowledge are not wide and thanks
you work in google colab?
yes
you have telegram, I can help you there?
Colab
!sed -i '759s/from_which_layer[fg_mask_inboxes]/from_which_layer.to(fg_mask_inboxes.device)[fg_mask_inboxes]/' /content/gdrive/MyDrive/yolov7/yolov7/utils/loss.py
!sed -n -e 759p /content/gdrive/MyDrive/yolov7/yolov7/utils/loss.py
I still get the error mentioned above.
Is there any news on a fix?
A lot of the code in this file is repeated, so it is important to fix all occurrences.
What worked for me is replacing all occurrences of the line
from_which_layer = torch.cat(from_which_layer, dim=0)
with
from_which_layer = torch.cat(from_which_layer, dim=0).to(targets.device)
I'm training yolov7 on a custom dataset using colab:
!python train.py --batch 12 --cfg cfg/training/yolov7_custom.yaml --epochs 50 --data data/custom_data.yaml --weights 'yolov7.pt' --device 0 and i face this issue below:
Traceback (most recent call last): File "train.py", line 616, in
train(hyp, opt, device, tb_writer)
File "train.py", line 363, in train
loss, loss_items = compute_loss_ota(pred, targets.to(device), imgs) # loss scaled by batchsize
File "/content/gdrive/MyDrive/yolov7/yolov7/utils/loss.py", line 585, in call
bs, as, gjs, gis, targets, anchors = self.build_targets(p, targets, imgs)
File "/content/gdrive/MyDrive/yolov7/yolov7/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)
please anyone can help me!