turandai / gaussian_surfels

Implementation of the SIGGRAPH 2024 conference paper "High-quality Surface Reconstruction using Gaussian Surfels".
501 stars 24 forks source link

Indexed tensor mismatch #15

Closed Iliceth closed 4 months ago

Iliceth commented 4 months ago

The training ran successfully, but when I then run

python render.py -m ./output/camera_2f66e742-c --img --depth 10

I get the error underneath and the process halts:

Looking for config file in ./output/camera_2f66e742-c/cfg_args Config file found: ./output/camera_2f66e742-c/cfg_args Rendering ./output/camera_2f66e742-c Loading trained model at iteration 15000 [12/05 18:32:45] Found camera.npz file, assuming IDR data format! [12/05 18:32:45] Generating random point cloud (1000000)... [12/05 18:32:48] Loading cameras: 144 for training and 0 for testing [12/05 18:32:48] Rendering progress: 0it [00:00, ?it/s] /home/user/miniconda3/envs/gaussian_surfels/lib/python3.10/site-packages/numpy/core/fromnumeric.py:3504: RuntimeWarning: Mean of empty slice. return _methods._mean(a, axis=axis, dtype=dtype, /home/user/miniconda3/envs/gaussian_surfels/lib/python3.10/site-packages/numpy/core/_methods.py:129: RuntimeWarning: invalid value encountered in scalar divide ret = ret.dtype.type(ret / rcount) Rendering progress: 0%| | 0/144 [00:00<?, ?it/s]/home/user/Documents/gaussian_surfels/utils/image_utils.py:86: UserWarning: Using torch.cross without specifying the dim arg is deprecated. Please either pass the dim explicitly or simply use torch.linalg.cross. The default value of dim will change to agree with that of linalg.cross in a future release. (Triggered internally at /opt/conda/conda-bld/pytorch_1711403380909/work/aten/src/ATen/native/Cross.cpp:63.) n_ul = torch.cross(p_u, p_l) Rendering progress: 100%|██████████████████████████████████████████████| 144/144 [01:34<00:00, 1.53it/s] Mesh refining: 50%|███████████████████████████▌ | 2/4 [00:46<00:46, 23.43s/it]Traceback (most recent call last): File "/home/user/Documents/gaussian_surfels/render.py", line 133, in <module> render_sets(model.extract(args), args.iteration, pipeline.extract(args), args.skip_train, args.skip_test, args.img, args.depth) File "/home/user/Documents/gaussian_surfels/render.py", line 112, in render_sets render_set(dataset.model_path, True, "train", scene.loaded_iter, scene.getTrainCameras(scales[0]), gaussians, pipeline, background, write_image, poisson_depth) File "/home/user/Documents/gaussian_surfels/render.py", line 88, in render_set poisson_mesh(mesh_path, resampled[:, :3], resampled[:, 3:6], resampled[:, 6:], poisson_depth, 1 * 1e-4) File "/home/user/Documents/gaussian_surfels/utils/general_utils.py", line 237, in poisson_mesh nn_color = torch.mean(color[nn_idx], axis=1) RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu) Mesh refining: 50%|███████████████████████████ | 2/4 [04:23<04:23, 131.83s/it]

Based on RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu) How can I make sure the "indexed tensor" is gpu instead of cpu?

gaetan-landreau commented 4 months ago

Hi. You just need to put nn_idx on the cpu on l.236 of _generalutils.py

nn_idx = nn_idx[0].cpu()
Iliceth commented 4 months ago

Hi. You just need to put nn_idx on the cpu on l.236 of _generalutils.py

nn_idx = nn_idx[0].cpu()

Thanks @gaetan-landreau ! Runs perfectly now.

turandai commented 4 months ago

Hi, sorry for the late reply. Like @Iliceth said, you can move the nn_idx tensor to the same device as the color tensor. Glad to here you have solved the problem