autonomousvision / gaussian-opacity-fields

Gaussian Opacity Fields: Efficient and Compact Surface Reconstruction in Unbounded Scenes
https://niujinshuchong.github.io/gaussian-opacity-fields/
Other
559 stars 26 forks source link

OOM when run extract_mesh.py #42

Open poorGiser opened 1 month ago

poorGiser commented 1 month ago

When I run extract_mesh.py for my custom data,I get OOM error in this code snippet. I use RTX 4090. code I want to know if it's because there are too many Gaussian in the scene or because of the graphics card. Thanks.

niujinshuchong commented 1 month ago

Hi, which scene are you testing? The currently implementation of marching tetrahedra requires a lot of GPU memory since it's purely based on pytorch.

You can try to change the code here https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/scene/gaussian_model.py#L379-L384 to use less gaussian for mesh extraction or try to change other hyperparameters (like here https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/train.py#L259) such that the final number of Gaussian after training is not that much

poorGiser commented 1 month ago

Thank you for your reply. I'm using a portion of the UAV dataset with about 470 images. The origin image resolution is 4591x3435, then I set -- -resolution 4 to downsample the image. when I extract the image, the vertices.shape, tets.shape, alpha.shape = torch.Size([1, 35472411, 3]) torch.Size([237834521, 4]) torch.Size([35472411]), I don't know if that's a lot. I will try your suggestions and get back to you, thank you.

niujinshuchong commented 4 weeks ago

Hi, 35M points is reasonable but you might be 24GB is not enough to run the marching tetrahedral algorithm. Are you able to extract the mesh by tuning the hyperparameters to use less Gaussians?

poorGiser commented 3 weeks ago

I changed https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/train.py#L259 to gaussians.densify_and_prune(opt.densify_grad_threshold, 0.1, scene.cameras_extent, size_threshold) to delete more gaussians, then I I successfully extracted the mesh .But I don't know if this will lead to a decrease in surface quality.

mawenjie1111 commented 3 weeks ago

I also have this problem,II have change the corresponding code to solve the OOM problem, but there have a new one. image it might because image lead to "index out of bounds". so ,how to solve this bug? I use RTX 3090

niujinshuchong commented 3 weeks ago

Hi, could you try to use a smaller chunk size here: https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/utils/tetmesh.py#L55

If this dosen't work, the other solution is to save the temporary results in cpu and only move the data to gpu when it is used by changing the code here: https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/utils/tetmesh.py#L52 but this might slow down the process significantly.

mawenjie1111 commented 3 weeks ago

Hi, could you try to use a smaller chunk size here: https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/utils/tetmesh.py#L55

If this dosen't work, the other solution is to save the temporary results in cpu and only move the data to gpu when it is used by changing the code here: https://github.com/autonomousvision/gaussian-opacity-fields/blob/main/utils/tetmesh.py#L52 but this might slow down the process significantly.

thank you for reply , i have solved this bug

niujinshuchong commented 3 weeks ago

@mawenjie1111 Could you please share your solution? I think that would be very helpful.