ashawkey / torch-ngp

A pytorch CUDA extension implementation of instant-ngp (sdf and nerf), with a GUI.
MIT License
2.11k stars 275 forks source link

raymarching.march_rays: RuntimeError: CUDA error: an illegal memory access was encountered #126

Closed RickyYXY closed 2 years ago

RickyYXY commented 2 years ago

I use raymarching.march_rays in my own code, like xyzs, dirs, deltas = raymarching.march_rays(n_alive, n_step, rays_alive, rays_t, rays_o, rays_d, self.coarse_net.bound, self.coarse_net.density_bitfield, self.coarse_net.cascade, self.coarse_net.grid_size, nears, fars, 128, perturb if step == 0 else False, self.opt.dt_gamma, self.opt.max_steps) I have checked that all my input tensors have the right data type and shape, but after executing raymarching.march_rays, all the returned tensors and input tensors become inaccessible. When I use print or use index and other ops in these tensors, I get results like: File "/mnt/data-4/yuxingyuan/temp_data/VoxMan-MeshPoint/trainers/vanilla_nerf_trainer.py", line 144, in loss_func rays_alive = rays_alive[rays_alive >= 0] RuntimeError: CUDA error: an illegal memory access was encountered

My device is V100 CUDA11.0, pytorch 1.8.0, python 3.7.13

RickyYXY commented 2 years ago

Sorry, I find the reason, one of my tensors is not on CUDA device and there is no device error appear.