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 the this code using gpu #10

Open
sunguwei opened this issue Oct 28, 2018 · 5 comments
Open

how to run the this code using gpu #10

sunguwei opened this issue Oct 28, 2018 · 5 comments

Comments

@sunguwei
Copy link

I found that it is a bit slow when I run this code. Then I check the usage of gpu and I found this code was run on the cpu. So I want to change the code to run on the gpu. But I found the type of weight of this model is torch.FloatTensor. Is that mean I cannot use the gpu to run this code directly? Is that any solution can help me to run this code on gpu?

Here is the error:
RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #2 'weight'

@oyxhust
Copy link

oyxhust commented Jan 14, 2019

I also meet this issue. Have you solve it?

@lianuo
Copy link

lianuo commented Jan 15, 2019

same issue

@BrightXiaoHan
Copy link

You can call .cuda() or to('gpu:0') to move model to gpu.
For example:

pnet = Pnet().cuda()
output = pnet(input_tensor)

@fuxuliu
Copy link

fuxuliu commented Mar 7, 2019

Like this, For example:
pnet.cuda() rnet.cuda() onet.cuda() offsets = output[0].cpu().data.numpy() probs = output[1].cpu().data.numpy()

finish the rest like that

@mayuanjason
Copy link

Hi sunguwei,

I just refactor this repo, you can check it in https://github.com/mayuanjason/MTCNN_face_detection_alignment_pytorch

It can run on GPU.

Here are some improvments I made:
• Transfer all numpy operation to torch operation, so that it can benefit from GPU acceleration.
• Automatic run on 'CPU' or 'GPU'.
• Based on the latest version of pytorch (1.3)
• Real-time face tracking

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

6 participants