-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Move only per-chunk data to the GPU to support rendering large images #2481
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, this seems fine to me! Just left one minor comment.
I agree that `output.to(input_device)` is cleaner (and it does work), but I
changed it to this form to make Pyright happy. (See the errors on the
initial commit of this PR).
…On Fri, Oct 20, 2023 at 9:42 PM Brent Yi ***@***.***> wrote:
***@***.**** approved this pull request.
Sorry for the delay, this seems fine to me! Just left one minor comment.
------------------------------
In nerfstudio/models/base_model.py
<#2481 (comment)>
:
> outputs = self.forward(ray_bundle=ray_bundle)
for output_name, output in outputs.items(): # type: ignore
if not torch.is_tensor(output):
# TODO: handle lists of tensors as well
continue
- outputs_lists[output_name].append(output)
+ # move the chunk outputs from the model device back to the device of the inputs.
+ outputs_lists[output_name].append(torch.as_tensor(output, device=input_device))
Does outputs_lists[output_name].append(output.to(input_device)) work? (it
seems equivalent, but semantically torch.as_tensor() makes me think that
output could be a numpy array)
—
Reply to this email directly, view it on GitHub
<#2481 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKTNQ4AAJJBXTOA64ZEWCLYAMSAHAVCNFSM6AAAAAA5MXSQ6KVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTMOJRGA2DMNRTGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
torch.is_tensor() doesn't have a TypeGuard annotation
Ok! I pushed a fix: the error seemed correct, since |
That seems like a much better solution, Thanks @brentyi ! |
Despite chunking of the rays for evaluation, there is a lot of full-image per-pixel data (inputs and outputs) still being stored on the GPU, which can be problematic when rendering very large images.
This change allows passing a CPU
camera_ray_bundle
toget_outputs_for_camera_ray_bundle()
. The per-chunk rays are moved to the GPU, and the per-chunk outputs are moved back to the device of the originalcamera_ray_bundle
.Behavior of existing code shouldn't change since inputs and outputs will still be stored completely on the GPU - it's just no longer a requirement.