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

[Bug fix ]Update pixel_samplers.py, tensor on different device, unpredictable behavior at assignment #2257

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Goulustis
Copy link

"indices" and "batch["image_idx"]" can be on different devices. The assignment between them, though will allow the model to converge correctly, have unpredictable behaviors. Namely, indices[:, 0] - batch["image_idx"][c].cpu() != 0. Putting them on the same device to have correct behavior.

It is a mystery to me why nerfstudio can work correctly with this unpredictable behavior.

@@ -105,6 +105,7 @@ def collate_image_dataset_batch(self, batch: Dict, num_rays_per_batch: int, keep
assert collated_batch["image"].shape[0] == num_rays_per_batch

# Needed to correct the random indices to their actual camera idx locations.
indices = indices.to(batch["image_idx"].device)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary since the line 109 below basically does the same thing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because after 109 the contents of indices[:, 0] does not equal to batch["image_idx"][c] if they are not on the same device.

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

Successfully merging this pull request may close these issues.

None yet

2 participants