ashawkey / torch-ngp

A pytorch CUDA extension implementation of instant-ngp (sdf and nerf), with a GUI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GridEncoder can't handle empty positions

ahmadki opened this issue · comments

Calling GridEncoder with empty positions positions.shape=[0, 3] causes CUDA to enter an invalid state silently. Subsequent calls to CUDA kernels would fail with the following error:

RuntimeError: CUDA error: invalid configuration argument

More info: nerfstudio-project/nerfacc#207 (comment)

minimal code to repro:

import GridEncoder
import torch

input_dim=3
multires=6
num_levels=16
level_dim=2
base_resolution=16
log2_hashmap_size=19
desired_resolution=2048
align_corners=False
interpolation='linear'
bound = torch.ones(1, device="cuda")
positions = torch.randn(0, 3, device="cuda", dtype=torch.float32) # Notice the empty positions

encoder = GridEncoder(input_dim=input_dim, num_levels=num_levels, level_dim=level_dim, base_resolution=base_resolution, log2_hashmap_size=log2_hashmap_size, desired_resolution=desired_resolution, gridtype='hash', align_corners=align_corners, interpolation=interpolation)
dummy = torch.zeros((1000,), device="cuda", dtype=torch.int64) # Works
enc = encoder(positions, bound=bound, max_level=None)
dummy = torch.zeros((1000,), device="cuda", dtype=torch.int64) # Failes