ashawkey / nerf2mesh

[ICCV2023] Delicate Textured Mesh Recovery from NeRF via Adaptive Surface Refinement
https://me.kiui.moe/nerf2mesh/
MIT License
908 stars 88 forks source link

ninja: build stopped: subcommand failed. #25

Open rohitdhote111 opened 1 year ago

rohitdhote111 commented 1 year ago

I am using docker container (pytorch/pytorch:1.13.0-cuda11.6-cudnn8-devel)

Training got completed but faced below error while saving mesh on sample lego dataset

++> Evaluate epoch 300 Finished. Loading test data: 100%|██████████████████████| 200/200 [00:02<00:00, 71.51it/s] ++> Evaluate at epoch 300 ... loss=0.000199 (0.000249): : 100% 200/200 [01:10<00:00, 2.84it/s] PSNR = 33.700192 SSIM = 0.972311 LPIPS (vgg) = 0.043763 ++> Evaluate epoch 300 Finished. ==> Start Test, save results to trial_syn_lego/results 100% 200/200 [00:29<00:00, 7.17it/s]==> Finished Test. 100% 200/200 [00:34<00:00, 5.87it/s] ==> Saving mesh to trial_syn_lego/mesh_stage0 Traceback (most recent call last): File "/opt/conda/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1900, in _run_ninja_build subprocess.run( File "/opt/conda/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/data2/nerf2mesh/main.py", line 241, in trainer.save_mesh(resolution=opt.mcubes_reso, decimate_target=opt.decimate_target, dataset=train_loader._data if opt.mesh_visibility_culling else None) File "/home/data2/nerf2mesh/nerf/utils.py", line 871, in save_mesh self.model.export_stage0(save_path, resolution=resolution, decimate_target=decimate_target, dataset=dataset) File "/opt/conda/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, *kwargs) File "/home/data2/nerf2mesh/nerf/renderer.py", line 486, in export_stage0 visibility_mask = self.mark_unseen_triangles(vertices, triangles, dataset.mvps, dataset.H, dataset.W).cpu().numpy() File "/opt/conda/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(args, **kwargs) File "/home/data2/nerf2mesh/nerf/renderer.py", line 818, in mark_unseen_triangles self.glctx = dr.RasterizeGLContext(output_db=False) File "/opt/conda/lib/python3.9/site-packages/nvdiffrast/torch/ops.py", line 221, in init self.cpp_wrapper = _get_plugin(gl=True).RasterizeGLStateWrapper(output_db, mode == 'automatic', cuda_device_idx) File "/opt/conda/lib/python3.9/site-packages/nvdiffrast/torch/ops.py", line 118, in _get_plugin torch.utils.cpp_extension.load(name=plugin_name, sources=source_paths, extra_cflags=opts, extra_cuda_cflags=opts+['-lineinfo'], extra_ldflags=ldflags, with_cuda=True, verbose=False) File "/opt/conda/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1284, in load return _jit_compile( File "/opt/conda/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1508, in _jit_compile _write_ninja_file_and_build_library( File "/opt/conda/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1623, in _write_ninja_file_and_build_library _run_ninja_build( File "/opt/conda/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1916, in _run_ninja_build raise RuntimeError(message) from e RuntimeError: Error building extension 'nvdiffrast_plugin_gl': [1/1] c++ common.o glutil.o rasterize_gl.o torch_bindings_gl.o torch_rasterize_gl.o -shared -lGL -lEGL -L/opt/conda/lib/python3.9/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/opt/conda/lib64 -lcudart -o nvdiffrast_plugin_gl.so FAILED: nvdiffrast_plugin_gl.so c++ common.o glutil.o rasterize_gl.o torch_bindings_gl.o torch_rasterize_gl.o -shared -lGL -lEGL -L/opt/conda/lib/python3.9/site-packages/torch/lib -lc10 -lc10_cuda -ltorch_cpu -ltorch_cuda_cu -ltorch_cuda_cpp -ltorch -ltorch_python -L/opt/conda/lib64 -lcudart -o nvdiffrast_plugin_gl.so /usr/bin/ld: cannot find -lcudart collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

ashawkey commented 1 year ago

@rohitdhote111 Hi, this seems to be a problem with nvdiffrast, could you check its installation and try their examples here?

rohitdhote111 commented 1 year ago

@ashawkey Hi, Thanks for reply. I tried installing nvdiffrast separately but there also it failed. Please let me know any solution. If you can please provide any docker image environment for this.

roshanpuru commented 1 year ago

Error clearly says: /opt/conda/lib/python3.9/site-packages/nvdiffrast/common/glutil.h:36:10: fatal error: EGL/egl.h: No such file or directory

include <EGL/egl.h>

You don't have the right mse package installed. Docker will have this trouble, I would suggest move to non-docker environment.

nangongliufeng commented 1 year ago

try run"apt-get update apt-get install libgl1-mesa-dev"