qfgaohao/pytorch-ssd

cannot run run_ssd_example.py on cuda

ynjiun opened this issue · 2 comments

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.

@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.

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