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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

cameras_from_opencv_projection always instantiates cameras on the CPU side #1021

Closed
rbregier opened this issue Jan 6, 2022 · 0 comments
Closed

Comments

@rbregier
Copy link

rbregier commented Jan 6, 2022

馃悰 Bugs / Unexpected behaviors

Hi,
the function cameras_from_opencv_projection instantiates cameras on the CPU side when provided with GPU tensors.

I believe that passing an additional parameter device=R.device to the following constructor should solve the issue:

return PerspectiveCameras(

Best,
Romain

Instructions To Reproduce the Issue:

import torch
import pytorch3d.utils

device = torch.device(0)

R = torch.eye(3, device=device)[None]
tvec = torch.zeros(1, 3, device=device)
camera_matrix = torch.eye(3, device=device)[None]
image_size = torch.as_tensor([[320, 240]], device=device)

cameras = pytorch3d.utils.cameras_from_opencv_projection(R=R, tvec=tvec, camera_matrix=camera_matrix, image_size=image_size)

print("Input device", R.device)
print("Output device", cameras.R.device)

Output:

Input device cuda:0
Output device cpu

(expected output: cuda:0)

facebook-github-bot pushed a commit that referenced this issue Jan 21, 2022
Summary: Fix #1021 that cameras_from_opencv_projection always creates on CPU.

Reviewed By: nikhilaravi

Differential Revision: D33508211

fbshipit-source-id: fadebd45cacafd633af6a58094cf6f654529992c
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

1 participant