NVIDIAGameWorks / kaolin-wisp

NVIDIA Kaolin Wisp is a PyTorch library powered by NVIDIA Kaolin Core to work with neural fields (including NeRFs, NGLOD, instant-ngp and VQAD).
Other
1.46k stars 131 forks source link

RuntimeError: expected scalar type Double but found Float #185

Open jianhengLiu opened 1 year ago

jianhengLiu commented 1 year ago

python app/nglod/main_nglod.py --config app/nglod/configs/nglod_hash.yaml --blas.mesh-path spot.obj

When I run nglod example, it ran out this error.

Traceback (most recent call last):
File "/home/chrisliu/Projects/LidarNeRF/LVRF/submodules/kaolin-wisp/app/nglod/main_nglod.py", line 98, in
train_dataset: SDFDataset = instantiate(cfg.dataset, occupancy_struct=blas)
File "/home/chrisliu/anaconda3/envs/wisp/lib/python3.9/site-packages/wisp/config/utils.py", line 375, in instantiate
instance = instance(**args_for_partial)
File "/home/chrisliu/anaconda3/envs/wisp/lib/python3.9/site-packages/wisp/datasets/formats/octree_sdf_dataset.py", line 73, in init
self.load()
File "/home/chrisliu/anaconda3/envs/wisp/lib/python3.9/site-packages/wisp/datasets/base_datasets.py", line 106, in load
return self.load_singleprocess()
File "/home/chrisliu/anaconda3/envs/wisp/lib/python3.9/site-packages/wisp/datasets/formats/octree_sdf_dataset.py", line 167, in load_singleprocess
self.data_pool = self._sample_from_grid(blas=self.blas, samples_per_voxel=self.samples_per_voxel)
File "/home/chrisliu/anaconda3/envs/wisp/lib/python3.9/site-packages/wisp/datasets/formats/octree_sdf_dataset.py", line 140, in _sample_from_grid
d = mesh_ops.compute_sdf(vertices, faces, pts)
File "/home/chrisliu/anaconda3/envs/wisp/lib/python3.9/site-packages/wisp/ops/mesh/compute_sdf.py", line 42, in compute_sdf
print(_C.external.mesh_to_sdf_cuda(_p.cuda().contiguous(), mesh.cuda().contiguous()))
RuntimeError: expected scalar type Double but found Float

I noticed that 'float' was changed to 'double' in this commit https://github.com/NVIDIAGameWorks/kaolin-wisp/commit/246b1ec434c373bf2e649cc27b1ea04a4d73ebdb, while compute_sdf is still intake float Tensor.

And so far I change

sdfs.append(_C.external.mesh_to_sdf_cuda(_p.cuda().contiguous(), mesh.cuda().contiguous())[0])

into

sdfs.append(_C.external.mesh_to_sdf_cuda(_p.double().cuda().contiguous(), mesh.double().cuda().contiguous())[0])

to make it work