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: result type Float can't be cast to the desired output type long int #16

Open
tommylatranvu opened this issue Jun 27, 2023 · 2 comments

Comments

@tommylatranvu
Copy link

Hello Chen,
Thank you very much for taking your time to answer me! I appreciate!
When I run the training code train.py, I had the error:

Image sizes 512 train, 512 test
Using 8 dataloader workers
Logging results to LEVIR-Ship/exp2
Starting training for 1000 epochs...

 Epoch   gpu_mem       box       obj       cls       dgi     total   targets  img_size

0%| | 0/145 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/la/Desktop/DRENet_ship/train.py", line 515, in
train(hyp, opt, device, tb_writer, wandb)
File "/home/la/Desktop/DRENet_ship/train.py", line 294, in train
loss, loss_items, adaptParams = compute_loss(pred, dgimgs.to(device), targets.to(device)) # loss scaled by batch_size
File "/home/la/Desktop/DRENet_ship/utils/loss.py", line 135, in call
tcls, tbox, indices, anchors = self.build_targets(p[0], targets) # targets
File "/home/la/Desktop/DRENet_ship/utils/loss.py", line 245, in build_targets
indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
RuntimeError: result type Float can't be cast to the desired output type long int
wandb: Waiting for W&B process to finish... (failed 1). Press Control-C to abort syncing.

I did not change anything from your code. Could you please give me a solution to solve this problem. Thanks!

Best regards,

Tran-Vu

@WindVChen
Copy link
Owner

Hi @tommylatranvu ,

This is a problem caused by an incompatible torch version. You can find some discussions about this here.

And there are some simple and easy ways online to solve the problems, like this.

Hope these can help.

@tommylatranvu
Copy link
Author

Thanks a lot!

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