autonomousvision / sdfstudio

A Unified Framework for Surface Reconstruction
Apache License 2.0
1.96k stars 183 forks source link

Error occurred when calculating gradients of SDF w.r.t 3D points with HashGrid #257

Closed Nyohohoho closed 10 months ago

Nyohohoho commented 10 months ago

Hi, With HashGrid implemented by tinycudann, I encoded 3D points and estimated SDF via MLPs. I want to get normals, so I followed your implementation to calculate gradients with torch.autograd. But when losses backwarded, the following error occurred. I found that it is due to Eikonal Loss. So, could you give me a hint how you solved this problem? (Especially for BakedSDF)

File "/opt/conda/lib/python3.10/site-packages/tinycudann/modules.py", line 145, in backward doutput_grad, params_grad, input_grad = ctx.ctx_fwd.native_tcnn_module.bwd_bwd_input( RuntimeError: DifferentiableObject::backward_backward_input_impl: not implemented error

niujinshuchong commented 10 months ago

Hi, do you use the mlp from tcnn?

Nyohohoho commented 10 months ago

Hi, do you use the mlp from tcnn?

@niujinshuchong Thank you for your reply. Yes, I am also using MLP from tcnn. Is it the source of problem?

niujinshuchong commented 10 months ago

Hi, I think so. TCNN's mlps don't have second-order gradient supports. I think you can use Pytorch's MLP as we did here.

Nyohohoho commented 10 months ago

Hi, I think so. TCNN's mlps don't have second-order gradient supports. I think you can use Pytorch's MLP as we did here.

Thank you for your insightful suggestions. The problem is solved now.