weixin_39783633
2020-12-09 07:22 阅读 101

RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last): File "run_ssd_example.py", line 57, in boxes, labels, probs = predictor.predict(image, 10, 0.4) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict scores, boxes = self.net.forward(images) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward locations, self.priors, self.config.center_variance, self.config.size_variance File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2], RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

该提问来源于开源项目:shaoshengsong/MobileNetV3-SSD

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • weixin_39629679 weixin_39629679 2020-12-09 07:22

    Do you solve this problem?

    点赞 评论 复制链接分享
  • weixin_39759918 weixin_39759918 2020-12-09 07:22

    我也是同样的问题?

    点赞 评论 复制链接分享
  • weixin_39604819 weixin_39604819 2020-12-09 07:22

    请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last): File "run_ssd_example.py", line 57, in boxes, labels, probs = predictor.predict(image, 10, 0.4) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict scores, boxes = self.net.forward(images) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward locations, self.priors, self.config.center_variance, self.config.size_variance File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2], RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

    模型加载到cuda就行了

    点赞 评论 复制链接分享
  • weixin_39524048 weixin_39524048 2020-12-09 07:22

    If you are trying to use GPU, change device in create_mobilenetv3_ssd_lite_predictor to torch.device('cuda:0'), it works for me.

    点赞 评论 复制链接分享
  • weixin_39593469 weixin_39593469 2020-12-09 07:22

    thanks

    点赞 评论 复制链接分享
  • weixin_39615956 weixin_39615956 2020-12-09 07:22

    请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last): File "run_ssd_example.py", line 57, in boxes, labels, probs = predictor.predict(image, 10, 0.4) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict scores, boxes = self.net.forward(images) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward locations, self.priors, self.config.center_variance, self.config.size_variance File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2], RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

    模型加载到cuda就行了

    修改vision/ssd/mobilenet_v3_ssd_lite.py文件第90行成def create_mobilenetv3_ssd_lite_predictor(net, candidate_size=200, nms_method=None, sigma=0.5, device=torch.device('cuda:0'))就可以了。

    点赞 评论 复制链接分享
  • weixin_39847437 weixin_39847437 2020-12-09 07:22

    It is recommended that git clone this version https://github.com/shaoshengsong/MobileNetV3-SSD-Compact-Version

    点赞 评论 复制链接分享

相关推荐