yhenon / pytorch-retinanet

Pytorch implementation of RetinaNet object detection.
Apache License 2.0
2.14k stars 664 forks source link

RuntimeError: Expected object of backend CUDA but got backend CPU for ... #174

Open starhiking opened 4 years ago

starhiking commented 4 years ago

The original code doesn't consider the gpu situation for loss, and will lead to the problem: RuntimeError: Expected object of backend CUDA but got backend CPU for ...

original code: https://github.com/yhenon/pytorch-retinanet/blob/ef2c16f4ad66b652b836be36465ee63c978f3194/retinanet/losses.py#L64

change:

regression_losses.append(torch.tensor(0).float().cuda())

LIYHUI commented 4 years ago

It really works, but why?

starhiking commented 4 years ago

It really works, but why?

CUDA is avaliable for that situation

LIYHUI commented 4 years ago

It really works, but why?

CUDA is avaliable for that situation

thank you, I am not familiar with that, but I understand it now.

wvalcke commented 3 years ago

Was a PR created for this ? This really fixes an error in the code.