qfgaohao / pytorch-ssd

MobileNetV1, MobileNetV2, VGG based SSD/SSD-lite implementation in Pytorch 1.0 / Pytorch 0.4. Out-of-box support for retraining on Open Images dataset. ONNX and Caffe2 support. Experiment Ideas like CoordConv.
https://medium.com/@smallfishbigsea/understand-ssd-and-implement-your-own-caa3232cd6ad
MIT License
1.39k stars 529 forks source link

cannot run run_ssd_example.py on cuda #147

Closed ynjiun closed 3 years ago

ynjiun commented 3 years ago

Hi when I run run_ssd_example.py using GPU and got following error:

Traceback (most recent call last):
  File "run_ssd_example.py", line 56, in <module>
    boxes, labels, probs = predictor.predict(image, 10, 0.4)
  File "/home/paul/pytorch/PytorchProject/ssd/vision/ssd/predictor.py", line 37, in predict
    scores, boxes = self.net.forward(images)
  File "/home/paul/pytorch/PytorchProject/ssd/vision/ssd/ssd.py", line 93, in forward
    locations, self.priors, self.config.center_variance, self.config.size_variance
  File "/home/paul/pytorch/PytorchProject/ssd/vision/utils/box_utils.py", line 104, in convert_locations_to_boxes
    locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2],
RuntimeError: expected device cpu but got device cuda:0

It seems that box_utils.py cannot run on cuda device. Is there a quick fix for this such that I can run it on cuda device? Thank you very much for your help.

tensorturtle commented 3 years ago

@ynjiun I made a pull request that fixes this issue. It was a bug that is common to run_ssd_example.py and live examples as well.

ynjiun commented 3 years ago

@neuroquantifier cool. I incorporated your changes and it works! Thank you so much for your help.