ashawkey / torch-ngp

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

TypeError: _near_far_from_aabb.forward() takes from 4 to 5 positional arguments but 8 were given #121

Open fotfotfive opened 2 years ago

fotfotfive commented 2 years ago

I installed via conda, python 3.9, cuda 11.3 pytorch 1.11

but when I try to use ngp I get this error, not sure how to fix, any help would be very appreciated

(torch-ngp) C:\torch-ngp>python main_nerf.py data/fox --workspace trial_nerf --cuda_ray --gui --test Namespace(path='data/fox', O=False, test=True, workspace='trial_nerf', seed=0, iters=30000, lr=0.01, ckpt='latest', num_rays=4096, cuda_ray=True, max_steps=1024, num_steps=512, upsample_steps=0, update_extra_interval=16, max_ray_batch=4096, patch_size=1, fp16=False, ff=False, tcnn=False, color_space='srgb', preload=False, bound=2, scale=0.33, offset=[0, 0, 0], dt_gamma=0.0078125, min_near=0.2, density_thresh=10, bg_radius=-1, gui=True, W=1920, H=1080, radius=5, fovy=50, max_spp=64, error_map=False, clip_text='', rand_pose=-1) NeRFNetwork( (encoder): GridEncoder: input_dim=3 num_levels=16 level_dim=2 resolution=16 -> 4096 per_level_scale=1.4473 params=(6328848, 2) gridtype=hash align_corners=False (sigma_net): ModuleList( (0): Linear(in_features=32, out_features=64, bias=False) (1): Linear(in_features=64, out_features=16, bias=False) ) (encoder_dir): SHEncoder: input_dim=3 degree=4 (color_net): ModuleList( (0): Linear(in_features=31, out_features=64, bias=False) (1): Linear(in_features=64, out_features=64, bias=False) (2): Linear(in_features=64, out_features=3, bias=False) ) ) Setting up [LPIPS] perceptual loss: trunk [alex], v[0.1], spatial [off] Loading model from: C:\ProgramData\Anaconda3.9\envs\torch-ngp\lib\site-packages\lpips\weights\v0.1\alex.pth [INFO] Trainer: ngp | 2022-10-31_19-47-43 | cuda | fp32 | trial_nerf [INFO] #parameters: 12667040 [INFO] Loading latest checkpoint ... [WARN] No checkpoint found, model randomly initialized. Traceback (most recent call last): File "C:\torch-ngp\main_nerf.py", line 117, in gui = NeRFGUI(opt, trainer) File "C:\torch-ngp\nerf\gui.py", line 82, in init self.test_step() File "C:\torch-ngp\nerf\gui.py", line 128, in test_step outputs = self.trainer.test_gui(self.cam.pose, self.cam.intrinsics, self.W, self.H, self.bg_color, self.spp, self.downscale) File "C:\torch-ngp\nerf\utils.py", line 768, in test_gui preds, preds_depth = self.test_step(data, bg_color=bg_color, perturb=False if spp == 1 else spp) File "C:\torch-ngp\nerf\utils.py", line 563, in test_step outputs = self.model.render(rays_o, rays_d, staged=True, bg_color=bg_color, perturb=perturb, vars(self.opt)) File "C:\torch-ngp\nerf\renderer.py", line 572, in render results = _run(rays_o, rays_d, kwargs) File "C:\torch-ngp\nerf\renderer.py", line 268, in run_cuda nears, fars = raymarching.near_far_from_aabb(rays_o, rays_d, self.aabb_train if self.training else self.aabb_infer, self.min_near) File "C:\ProgramData\Anaconda3.9\envs\torch-ngp\lib\site-packages\torch\cuda\amp\autocast_mode.py", line 118, in decorate_fwd return fwd(*args, *kwargs) File "C:\torch-ngp\raymarching\raymarching.py", line 45, in forward _backend.near_far_from_aabb(rays_o, rays_d, aabb, N, min_near, nears, fars) File "C:\ProgramData\Anaconda3.9\envs\torch-ngp\lib\site-packages\torch\cuda\amp\autocast_mode.py", line 118, in decorate_fwd return fwd(args, **kwargs) TypeError: _near_far_from_aabb.forward() takes from 4 to 5 positional arguments but 8 were given

Tejas-Deo commented 1 year ago

I am also facing the same issue.

Did you solve it?

ashawkey commented 1 year ago

@fotfotfive @Tejas-Deo Could you try to reinstall the latest raymarching: pip install ./raymarching and try again?

Tejas-Deo commented 1 year ago

No, I still keep on getting the same error. Versions that I am using:

Nvidia-SMI: 510.108.03 Driver Version: 5101.08.03 Cuda version: 11.6

GCC Version: 11:3:0 G++ Version: 11:3:0

Pytorch Version: 1.13.0 Pytorch Build: py3.9_cuda11.7_cudnn8.5.0_0 Channel: pytorch

The same configuration works on a linux PC. I have my laptop dua booted and doesn't work when I install and run the same versions.

Error that I get:

Traceback (most recent call last): File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/main_nerf.py", line 165, in gui = NeRFGUI(opt, trainer, train_loader) File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/nerf/gui.py", line 92, in init self.test_step() File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/nerf/gui.py", line 132, in test_step outputs = self.trainer.test_gui(self.cam.pose, self.cam.intrinsics, File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/nerf/utils.py", line 1014, in test_gui preds, preds_depth = self.test_step(data, bg_color=bg_color, perturb=spp) File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/nerf/utils.py", line 758, in test_step outputs = self.model.render(rays_o, rays_d, staged=True, bg_color=bgcolor, File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/nerf/renderer.py", line 624, in render results = _run(rays_o[b:b+1, head:tail], rays_d[b:b+1, head:tail], File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/nerf/renderer.py", line 144, in run nears, fars = raymarching.near_far_from_aabb(rays_o, rays_d, aabb, self.min_near) File "/home/tejas/anaconda3/envs/torch/lib/python3.9/site-packages/torch/cuda/amp/autocast_mode.py", line 105, in decorate_fwd return fwd(*args, *kwargs) File "/home/tejas/Documents/Stanford/Nerf-By-Touch/torch-ngp/raymarching/raymarching.py", line 45, in forward _backend.near_far_from_aabb(rays_o, rays_d, aabb, N, min_near, nears, fars) File "/home/tejas/anaconda3/envs/torch/lib/python3.9/site-packages/torch/cuda/amp/autocast_mode.py", line 105, in decorate_fwd return fwd(args, **kwargs) TypeError: forward() takes from 4 to 5 positional arguments but 8 were given

Please can you help me with this?

Tejas-Deo commented 1 year ago

@fotfotfive @Tejas-Deo Could you try to reinstall the latest raymarching: pip install ./raymarching and try again?

Any update on this front?