-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
run_ssd_live_demo.py: "RuntimeError: expected device cpu but got device cuda:0" #89
Comments
So it looks like the issue is the locations tensor being a CPU tensor and priors being a CUDA tensor. On line 93 of vision/ssd/ssd.py I made the following change:
Which gets the live demo to work. But because mb1-ssd seems to work fine, I believe the issue occurs at some point prior to this and that the above fix is more of a workaround. I haven't fully reviewed the entire code base to know if there is a better fix. |
I ran into the same issue as @Jaftem. His workaround solved my problem. |
Since the demo shows the inference on CPU, you either want to pass pytorch-ssd/run_ssd_live_demo.py Line 41 in 7174f33
or explicitly move the model to gpu somewhere in run_ssd_live_demo.py
|
@Jaftem try changing line 50 on run_ssd_live_demo.py from this:
to this:
Initializing the Predictor class this way solves this issue without touching the SSD class.
So, this model may be intended to be used in mobile devices. |
As @Jaftem pointed out, this error is reproducible when running in a node with GPUs. Pytorch seems to be loading into GPU by default. Running this is a CPU only node works. |
Yep exactly, the issue comes from On my side I just forced the device to be cpu in ssd because that is why I need. However a better solution would be to add a parameter device to the mobilenet_v2_ssd_lite so that it can specify a device |
I got similar error when I run convert_to_caffe2_models.py to convert mobilenet_v2_ssd_lite model to onnx. |
Hi,
I trained a mb2-ssd-lite model with a subset (just 1 class) of Open Images on just 20 epochs. I'm now attempting to run the live demo with this model:
And I get the runtime error
I can run the live demo on the pretrained model as per the README's instrucitons without error. Any ideas?
The text was updated successfully, but these errors were encountered: