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

error in running demo.py #11

Closed
kishan1823 opened this issue Jun 8, 2021 · 18 comments
Closed

error in running demo.py #11

kishan1823 opened this issue Jun 8, 2021 · 18 comments

Comments

@kishan1823
Copy link

kishan1823 commented Jun 8, 2021

image

i am getting this issue on running demo.py. can you help me in resolving this error.

@kishan1823 kishan1823 reopened this Jun 8, 2021
@EEWenbinWu
Copy link

you can add the following three lines: pose = pose.to(device), shape=shape.to(device), mano = mano.to(device)

@EEWenbinWu
Copy link

but then I got this new pro:
image

@kishan1823
Copy link
Author

where should i add those lines

@EEWenbinWu
Copy link

after you get yourfirst pose, shape and mano

@kishan1823
Copy link
Author

after adding also, i am getting same error

@kishan1823
Copy link
Author

yes the error resolved by adding those 3 lines, but a new error raised
image

@EEWenbinWu
Copy link

I got the same problem.

@maitetsu
Copy link
Contributor

maitetsu commented Jun 8, 2021

My mother tongue is not English. I'm sorry for some grammatical mistakes.

  1. First of all, let me explain why the first error occurs. In the original manopth, if the pose parameter in the form of matrix, the input matrix will be SVD decomposed to ensure that these matrices must be rotation matrices. Please refer to line 165 of original "manopth/manolayer.py".
    屏幕截图 2021-06-08 221742
    After SVD decomposition, no matter the input pose parameter is on CPU or GPU, the output will be on GPU. In demo.py, the parameters of mano are all on the CPU, so the first error is raised.

  2. My solution is to modify manopth. Specifically, modify the batch of "manopth/rotproj.py". The result of modifying can be seen here. After modification, this function can ensure that the input and output are CPU or GPU. Just add "device = rotmat.device" and change "rotmat = rotmat.cuda()" to "rotmat = rotmat.to(device)", you can try.
    屏幕截图 2021-06-08 221944

@EEWenbinWu
Copy link

thanks a lot~ And could you please help us to solve the second error. https://user-images.githubusercontent.com/65106584/121189840-1f3b0080-c888-11eb-8d00-9e900fd04d13.png

@maitetsu
Copy link
Contributor

maitetsu commented Jun 8, 2021

Of course, putting mano on GPU is also a solution. As for your second problem, I think it is due to the mano.th_faces on GPU. When it is on CPU, open3d can be automatically converted to the format required by open3d, but can't on GPU. Just put mano.th_faces on CPU can fix. Like this: " mesh.triangles = open3d.utility.Vector3iVector(mano.th_faces.cpu()) "
屏幕截图 2021-06-08 222920

@EEWenbinWu
Copy link

thx

@kishan1823
Copy link
Author

thank you

@hammerstone18
Copy link

i want to konw why i had added everthing you said but i also can not run demo

@hammerstone18
Copy link

File "D:\Minimal-Hand-pytorch-main\demo.py", line 120, in <module> _, j3d_p0_ops = mano(pose0, opt_tensor_shape) File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "D:\Minimal-Hand-pytorch-main\manopth\manolayer.py", line 181, in forward th_v_shaped = torch.matmul(self.th_shapedirs, RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method wrapper_mm)

@MengHao666
Copy link
Owner

a solution. As for your second problem, I think it is due to the mano.th_faces on GPU. When it is on CPU, open3d can be automatically converted to the format required by open3d, but can't on GPU. Just put mano.th_faces on CPU can fix. Like this: " mesh.triangles = open3d.utility.Vector3iVector(mano.th_faces.cpu()) "

it seems two arguments are not in same device, please check this issue carfully.

@hammerstone18
Copy link

hammerstone18 commented Apr 3, 2022

yeah i solved this problem but when running the demo.py i cannot display the plot

@MengHao666
Copy link
Owner

MengHao666 commented Apr 3, 2022 via email

@qwer904
Copy link

qwer904 commented Oct 21, 2023

File "D:\Minimal-Hand-pytorch-main\demo.py", line 120, in <module> _, j3d_p0_ops = mano(pose0, opt_tensor_shape) File "C:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "D:\Minimal-Hand-pytorch-main\manopth\manolayer.py", line 181, in forward th_v_shaped = torch.matmul(self.th_shapedirs, RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument mat2 in method wrapper_mm)

I had the same problem as you, have you solved it yet?

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