Open DaiGuard opened 2 years ago
From wath I can tell, of the two valiables (locations
, priors
), priors
seems to be in cuda mode.
# add this code in box_utils.py line: 104
print(locations.is_cuda)
print(priors.is_cuda)
---
False
True
Therefore, the following code could be added for use
# priors can have one dimension less.
if priors.dim() + 1 == locations.dim():
priors = priors.unsqueeze(0)
+ if priors.is_cuda:
+ priors = priors.to('cpu')
return torch.cat([
locations[..., :2] * center_variance * priors[..., 2:] + priors[..., :2],
torch.exp(locations[..., 2:] * size_variance) * priors[..., 2:]
], dim=locations.dim() - 1)
https://github.com/qfgaohao/pytorch-ssd/blob/master/vision/ssd/ssd.py#L38
priors
is saved in cuda device if you run with GPUs.
Another walkaway solution would be simply to run by
CUDA_VISIBLE_DEVICES='' python3 run_ssd_live_demo2.py mb2-ssd-lite models/mb2-ssd-lite-mp-0_686.pth models/voc-model-labels.txt <TEST_IMG>.jpg
I simply commented it out
self.priors = config.priors #.to(self.device)
https://github.com/qfgaohao/pytorch-ssd/pull/189 https://github.com/qfgaohao/pytorch-ssd/pull/189/commits/f9de9738f56a6844adc8375f217deabb7767dd20
Hello. With the modification below, I was able to get it to work as expected on both CPU and GPU environments. MobileNetV1 has the same implementation and runs without problems in the GPU environment. I think it was probably a simple mistake.
Hello
I'm trying to use this repo to run live demo to use mobielnet-ssd-v2. I tried to run
python run_ssd_live_demo.py mb2-ssd-lite models/mb2-ssd-lite-mp-0_686.pth models/voc-model-labels.txt
.I got this error as output
Environments OS: Ubuntu 18.04 GPU: NVIDIA GeForce RTX 2070 SUPER DRIVER: 515.65.01 CUDA: 11.6
Dependecies torch==1.10.2 torchaudio==0.10.1 torchvision==0.11.2 opencv-python==4.6.0.66