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

Added forward pass for depth rendering #2

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

Conversation

JonathonLuiten
Copy link

Adds CUDA code to also render the depth map (as well as the color map). Note this is ONLY the forward pass for this, feeding gradients back through this depth map won't work.

Note, it is unclear if this will result in slower rendering (my guess is that it shouldn't), but someone should check this probably before merging (e.g. train on garden with and without these changes), and if it is slower, then it should be added with a flag and off by default.

Also note that this by itself with break the main gaussian_splatting repo, so there needs to be the corresponding PR there merged too simultaneously. I will make a PR for that there too now.

@JonathonLuiten
Copy link
Author

The required changes to the main repo can be found in the following PR:
graphdeco-inria/gaussian-splatting#20

@JonathonLuiten
Copy link
Author

Hey @grgkopanas and @Snosixtyboo

I ran the speed test on this (tanks and temples / truck for 7000 iterations)

It results in 0 slowdown. I think it's safe to merge this.

Results:

WITH CHANGE:

Training progress: 23%|██▎ | 7000/30000 [02:50<12:04, 31.74it/s, Loss=0.0588340]
[ITER 7000] Evaluating train: L1 0.033260490745306015 PSNR 24.68514633178711 [13/07 15:25:22]

ORIGINAL:

Training progress: 23%|██▎ | 7000/30000 [02:50<12:07, 31.60it/s, Loss=0.0594036]
[ITER 7000] Evaluating train: L1 0.03345547989010811 PSNR 24.60102653503418 [13/07 15:32:42]

@BennetLeff
Copy link

feeding gradients back through this depth map won't work

Could you say why? Thanks!

@JonathonLuiten
Copy link
Author

Because the backward pass for the depth hasn't been implemented. Unlike pytorch, the backward pass isn't automatically calculated in CUDA, and has to be written by hand.

@BennetLeff
Copy link

Ahh, by the way you had written it, I thought there was some more grand technical fault. Thanks!

@ray8828
Copy link

ray8828 commented Sep 18, 2023

I always get memory error of this version with depth, seems there is hidden memory bug in this depth version

CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

@nishadgothoskar
Copy link

I'm curious whether a backward pass has been implemented for this

sairisheek pushed a commit to sairisheek/diff-gaussian-rasterization that referenced this pull request Oct 6, 2023
@@ -370,6 +378,7 @@ renderCUDA(
n_contrib[pix_id] = last_contributor;
for (int ch = 0; ch < CHANNELS; ch++)
out_color[ch * H * W + pix_id] = C[ch] + T * bg_color[ch];
out_depth[pix_id] = D;
Copy link

Choose a reason for hiding this comment

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

should it be D / (1 - T) here?

Choose a reason for hiding this comment

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

@jb-ye I think so, too.

@zcc00210
Copy link

Adds CUDA code to also render the depth map (as well as the color map). Note this is ONLY the forward pass for this, feeding gradients back through this depth map won't work.

Note, it is unclear if this will result in slower rendering (my guess is that it shouldn't), but someone should check this probably before merging (e.g. train on garden with and without these changes), and if it is slower, then it should be added with a flag and off by default.

Also note that this by itself with break the main gaussian_splatting repo, so there needs to be the corresponding PR there merged too simultaneously. I will make a PR for that there too now.

Hi,
May I ask why after I use your depth visualization cuda code under this branch, each pixel of the rendered depth map output is 255,255,255?
Your prompt reply will be highly appreciated!@JonathonLuiten

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.

7 participants