error in running demo.py
kishan1823 opened this issue · 18 comments
you can add the following three lines: pose = pose.to(device), shape=shape.to(device), mano = mano.to(device)
where should i add those lines
after you get yourfirst pose, shape and mano
after adding also, i am getting same error
I got the same problem.
My mother tongue is not English. I'm sorry for some grammatical mistakes.
-
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".
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. -
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.
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
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()) "
thx
thank you
i want to konw why i had added everthing you said but i also can not run demo
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)
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.
yeah i solved this problem but when running the demo.py i cannot display the plot
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?