训练D-NeRF模型时报错
报错内容:
Traceback (most recent call last): File "run_dnerf.py", line 957, in <module> train() File "run_dnerf.py", line 694, in train savedir=testsavedir, render_factor=args.render_factor, save_also_gt=True) File "run_dnerf.py", line 185, in render_path rgb, disp, acc, _ = render(H, W, focal, chunk=chunk, c2w=c2w[:3,:4], frame_time=frame_time, **render_kwargs) File "run_dnerf.py", line 151, in render all_ret = batchify_rays(rays, chunk, **kwargs) File "run_dnerf.py", line 83, in batchify_rays ret = render_rays(rays_flat[i:i+chunk], **kwargs) File "run_dnerf.py", line 449, in render_rays z_samples = sample_pdf(z_vals_mid, weights[...,1:-1], N_importance, det=(perturb==0.), pytest=pytest) File "E:NeRFD-NeRF-main un_dnerf_helpers.py", line 332, in sample_pdf inds = searchsorted(cdf, u, side='right') File "E:Anacondaenvsdnerflibsite-packages orchsearchsortedsearchsorted.py", line 41, in searchsorted raise Exception('torchsearchsorted on CUDA device is asked, but it seems ' Exception: torchsearchsorted on CUDA device is asked, but it seems that it is not available. Please install it
查了一下torchsearchsorted官方的说明,是找不到对应的CUDA版本导致。
后面又查了一下,发现pytorch在1.7以后已经内置了一个torch.searchsorted模块,不用再另外单独安装torchsearchsorted了,因此此处只需要修改一下代码就行。
找到run_dnerf_helpers.py中的报错位置,将:
inds = searchsorted(cdf, u, side='right')
改为:
inds = torch.searchsorted(cdf, u, right=True)
然后注释掉run_dnerf_helpers.py开头导入的torchsearchsorted包。
之后就能成功运行。