nerf2mesh icon indicating copy to clipboard operation
nerf2mesh copied to clipboard

Build errors, Windows

Open antithing opened this issue 2 years ago β€’ 16 comments

Hi, I am trying to build following your instruction, and when i run πŸ‘

cd raymarching
python setup.py build_ext --inplace

I see the following:

 Creating library D:\NERF\SDF\nerf2mesh\raymarching\build\temp.win-amd64-cpython-39\Release\NERF\SDF\nerf2mesh\raymarching\src\_raymarching_mob.cp39-win_amd64.lib and object D:\NERF\SDF\nerf2mesh\raymarching\build\temp.win-amd64-cpython-39\Release\NERF\SDF\nerf2mesh\raymarching\src\_raymarching_mob.cp39-win_amd64.exp
bindings.obj : error LNK2001: unresolved external symbol "void __cdecl composite_rays(unsigned int,unsigned int,float,bool,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor)" (?composite_rays@@YAXIIM_NVTensor@at@@1111111@Z)
  Hint on symbols that are defined and could potentially match:
    "void __cdecl composite_rays(unsigned int,unsigned int,float,bool,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor,class at::Tensor)" (?composite_rays@@YAXIIM_NVTensor@at@@1V12@22111@Z)
build\lib.win-amd64-cpython-39\_raymarching_mob.cp39-win_amd64.pyd : fatal error LNK1120: 1 unresolved externals
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x64\\link.exe' failed with exit code 1120

What can i try to get this running properly?

Thank you!

antithing avatar May 05 '23 12:05 antithing

Ah, i have solved this based on this comment:

https://github.com/ashawkey/stable-dreamfusion/issues/17#issuecomment-1271845828

and have made these changes: (removing const from the at:Tensor variables

-void composite_rays(const uint32_t n_alive, const uint32_t n_step, const float T_thresh, at::Tensor rays_alive, at::Tensor rays_t, const at::Tensor sigmas, const at::Tensor rgbs, const at::Tensor deltas, at::Tensor weights, at::Tensor depth, at::Tensor image) {

+void composite_rays(const uint32_t n_alive, const uint32_t n_step, const float T_thresh, at::Tensor rays_alive, at::Tensor rays_t, at::Tensor sigmas, at::Tensor rgbs, at::Tensor deltas, at::Tensor weights, at::Tensor depth, at::Tensor image) {

antithing avatar May 05 '23 12:05 antithing

@antithing Thanks for reporting and sorry for that, I'll fix it soon.

ashawkey avatar May 05 '23 12:05 ashawkey

Thanks! One more thing to report...

i have run the first stage successfully, now i am running:

python main.py data/garden/ --workspace trial_360_garden -O --data_format colmap --bound 16 --enable_cam_center --enable_cam_near_far --scale 0.3 --downscale 4 --stage 1 --iters 10000

And i get the following error:

0% 0/161 [00:00<?, ?it/s]Traceback (most recent call last):
 File "D:\NERF\SDF\nerf2mesh\main.py", line 243, in <module>
   trainer.train(train_loader, valid_loader, max_epoch)
 File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 931, in train
   self.train_one_epoch(train_loader)
 File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 1164, in train_one_epoch
   preds, truths, loss_net = self.train_step(data)
 File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 720, in train_step
   self.model.update_triangles_errors(loss.detach())
 File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
   return func(*args, **kwargs)
 File "D:\NERF\SDF\nerf2mesh\nerf\renderer.py", line 854, in update_triangles_errors
   import torch_scatter
 File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_scatter\__init__.py", line 16, in <module>
   torch.ops.load_library(spec.origin)
 File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\_ops.py", line 255, in load_library
   ctypes.CDLL(path)
 File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
   self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found
 0% 0/161 [00:25<?, ?it/s]

antithing avatar May 05 '23 13:05 antithing

Have you installed torch-scatter correctly? You could check here for Windows binaries or build it from source.

ashawkey avatar May 05 '23 13:05 ashawkey

Ah, you are right. This was because I had scatter installed for a different CUDA version than torch. Resolved! Thanks again. :)

antithing avatar May 05 '23 13:05 antithing

Ah, but I get another error! training starts, then:

 refine and decimate mesh at 1000 step
Traceback (most recent call last):
  File "D:\NERF\SDF\nerf2mesh\main.py", line 243, in <module>
    trainer.train(train_loader, valid_loader, max_epoch)
  File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 931, in train
    self.train_one_epoch(train_loader)
  File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 1206, in train_one_epoch
    self.model.refine_and_decimate()
  File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\NERF\SDF\nerf2mesh\nerf\renderer.py", line 219, in refine_and_decimate
    mask[(errors > thresh_refine) & cnt_mask] = 2
IndexError: boolean index did not match indexed array along dimension 0; dimension is 870831 but corresponding boolean dimension is 299999
loss=0.006328 (0.006733) lr=0.000089: :  21% 34/161 [00:05<00:21,  5.97it/s]

antithing avatar May 05 '23 14:05 antithing

I try the same with --sdf and i see:


 refine and decimate mesh at 1000 step
Traceback (most recent call last):
  File "D:\NERF\SDF\nerf2mesh\main.py", line 243, in <module>
    trainer.train(train_loader, valid_loader, max_epoch)
  File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 931, in train
    self.train_one_epoch(train_loader)
  File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 1206, in train_one_epoch
    self.model.refine_and_decimate()
  File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\NERF\SDF\nerf2mesh\nerf\renderer.py", line 251, in refine_and_decimate
    cur_v, cur_f = decimate_and_refine_mesh(cur_v, cur_f, mask, decimate_ratio=self.opt.refine_decimate_ratio, refine_size=self.opt.refine_size, refine_remesh_size=self.opt.refine_remesh_size)
  File "D:\NERF\SDF\nerf2mesh\meshutils.py", line 199, in decimate_and_refine_mesh
    m = pml.Mesh(verts, faces, f_scalar_array=mask)
pymeshlab.pmeshlab.PyMeshLabException: Error while creating mesh: the number of face quality values is different from the number of faces.

antithing avatar May 05 '23 16:05 antithing

Hi @ashawkey sorry to bother you, do you have any thoughts on what might be going wrong for me here? Thanks again!

antithing avatar May 08 '23 13:05 antithing

Both seem strange to me, and they seem to indicate something wrong with the extracted mesh. Could you check the mesh from stage0? Are you using a custom dataset?

ashawkey avatar May 08 '23 14:05 ashawkey

I am using the mipnerf360/garden dataset. I am running:

python main.py data/garden/ --workspace trial_360_garden -O --data_format colmap --bound 16 --enable_cam_center --enable_cam_near_far --scale 0.3 --downscale 4 --stage 0 --lambda_entropy 1e-3 --clean_min_f 16 --clean_min_d 10 --lambda_tv 2e-8 --visibility_mask_dilation 50

for stage 0, and then:

python main.py data/garden/ --workspace trial_360_garden -O --data_format colmap --bound 16 --enable_cam_center --enable_cam_near_far --scale 0.3 --downscale 4 --stage 1 --iters 10000

for stage 1

the dtage 0 mesh output folder looks like:

image

And the mesh_0.ply looks like:

image

antithing avatar May 08 '23 14:05 antithing

Sorry it's my mistake, I have fixed it in the latest commit. Thanks for reporting this bug!

ashawkey avatar May 09 '23 03:05 ashawkey

Thank you! It works :)

One more question, what settings should I change to get a smoother output mesh? I am using the example commands, and i get:

image

Thank you again!

antithing avatar May 09 '23 08:05 antithing

You may use --sdf if aiming at smooth mesh, but currently it only supports object-centric captures, and not suitable for 360 dataset (you need to remove the background for best mesh quality).

ashawkey avatar May 09 '23 10:05 ashawkey

I try the same with --sdf and i see:


 refine and decimate mesh at 1000 step
Traceback (most recent call last):
  File "D:\NERF\SDF\nerf2mesh\main.py", line 243, in <module>
    trainer.train(train_loader, valid_loader, max_epoch)
  File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 931, in train
    self.train_one_epoch(train_loader)
  File "D:\NERF\SDF\nerf2mesh\nerf\utils.py", line 1206, in train_one_epoch
    self.model.refine_and_decimate()
  File "C:\Users\B\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\NERF\SDF\nerf2mesh\nerf\renderer.py", line 251, in refine_and_decimate
    cur_v, cur_f = decimate_and_refine_mesh(cur_v, cur_f, mask, decimate_ratio=self.opt.refine_decimate_ratio, refine_size=self.opt.refine_size, refine_remesh_size=self.opt.refine_remesh_size)
  File "D:\NERF\SDF\nerf2mesh\meshutils.py", line 199, in decimate_and_refine_mesh
    m = pml.Mesh(verts, faces, f_scalar_array=mask)
pymeshlab.pmeshlab.PyMeshLabException: Error while creating mesh: the number of face quality values is different from the number of faces.

Hi, I am receiving the same error when using SDF with the latest commit. BTW, amazing project. I'm looking into the details right now, hoping to contribute as well. @ashawkey πŸš€πŸš€

aKn1ghtOut avatar May 09 '23 15:05 aKn1ghtOut

Hi, SDF mode is currently only suitable for single-object datasets with bound == 1. For the garden dataset, you could try the original NeRF mode.

ashawkey avatar May 10 '23 07:05 ashawkey

after pull the lastest version, I still meet the same problem when I run 'python setup.py build_ext --inplace'

build\lib.win-amd64-cpython-39_raymarching_mob.cp39-win_amd64.pyd : fatal error LNK1120: 3 δΈͺζ— ζ³•θ§£ζžηš„ε€–ιƒ¨ε‘½δ»€ error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe' failed with exit code 1120

r530044129 avatar May 15 '23 01:05 r530044129