Skip to content
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

fix a model inference problem on cpu #502

Merged
merged 3 commits into from
Aug 16, 2022
Merged

fix a model inference problem on cpu #502

merged 3 commits into from
Aug 16, 2022

Conversation

spacewalk01
Copy link
Contributor

@spacewalk01 spacewalk01 commented Aug 13, 2022

  1. I run keypoint.ipynb on a cpu-machine (macbook). And I got the following problem:
----> 2 weigths = torch.load('yolov7-w6-pose.pt')
...
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
  1. So, as it suggests, I have added map_location=torch.device(device) option to load function but it turns out one of the convolutions used in the model was not designed for 'half' precision when running on cpu and I got the following error.

RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'

  1. Then, I removed half precision option from the notebook and added _ = model.float().eval() to run it on both cpu and gpu machines.
    I suppose a lot of folks like me will try it on cpu for demo test.

I have tested the fixed code on both cpu and gpu in google colab and the link is here:
https://colab.research.google.com/drive/1kqdVq-n8I0EcPRA2g7YYK70rArUmy6Ai?usp=sharing

@spacewalk01
Copy link
Contributor Author

spacewalk01 commented Aug 16, 2022

@spacewalk01
Copy link
Contributor Author

@AlexeyAB

tools/keypoint.ipynb Outdated Show resolved Hide resolved
tools/keypoint.ipynb Outdated Show resolved Hide resolved
@spacewalk01
Copy link
Contributor Author

Edited as you suggested and tested it on colab. Thank you for the review.

@AlexeyAB AlexeyAB merged commit 064c71e into WongKinYiu:main Aug 16, 2022
@spacewalk01 spacewalk01 deleted the fix-keypoint-cpu branch August 16, 2022 13:36
TakanariShimbo pushed a commit to TakanariShimbo/yolov7 that referenced this pull request Aug 20, 2022
* fix model inference problem on cpu

* Update keypoint.ipynb
TakanariShimbo pushed a commit to TakanariShimbo/yolov7 that referenced this pull request Aug 20, 2022
wheemyungshin-nota pushed a commit to wheemyungshin/yolov7 that referenced this pull request Dec 1, 2023
* fix model inference problem on cpu

* Update keypoint.ipynb
nelioasousa pushed a commit to nelioasousa/yolov7 that referenced this pull request Apr 26, 2024
* fix model inference problem on cpu

* Update keypoint.ipynb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants