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

how to run "run_webcam.py" on gpu #28

Closed
2p990i9hpral opened this issue Apr 23, 2019 · 2 comments
Closed

how to run "run_webcam.py" on gpu #28

2p990i9hpral opened this issue Apr 23, 2019 · 2 comments

Comments

@2p990i9hpral
Copy link
Contributor

2p990i9hpral commented Apr 23, 2019

I changed ".to("cpu")" code to ".to("cuda")."
but it print below error and not work

RuntimeError: Expected object of backend CPU but got backend CUDA for argument #2 'weight'

how i can run this code use gpu?
i really want your advice
thank you!

@2p990i9hpral 2p990i9hpral changed the title how to run run_webcam on gpu how to run "run_webcam.py" on gpu Apr 23, 2019
@2p990i9hpral
Copy link
Contributor Author

i solved this problem

  1. convert network to cuda
    net = net.to('cuda')

  2. convert network input tensor to cuda
    keypoints = self.net(image.to("cuda"))

  3. convert output tensor to cpu
    keypoints = keypoints[0].detach().cpu().numpy()

@YuliangXiu
Copy link
Owner

thanks for your solution.

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

No branches or pull requests

2 participants