yzslab / gaussian-splatting-lightning

A 3D Gaussian Splatting framework with various derived algorithms and an interactive web viewer
Other
457 stars 38 forks source link

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 76.40 GiB (GPU 0; 8.00 GiB total capacity; 365.94 MiB already allocated; 6.55 GiB free; 400.00 MiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF #8

Closed wsAndy closed 10 months ago

wsAndy commented 10 months ago

in windows, I use docker image and render the trained ply by the following command:

set TrainOutputPath="E:\docker\data\tandt_db\tandt\train"
set ViewerPath="./"
docker run --name  viewer_97f459dee22843aaa728ded6999cf6ab -it --rm --gpus all -p 8080:8080 -v %ViewerPath%:/root/code -v %TrainOutputPath%:/root/data wsandy95/cuda:11.1-devel-ubuntu2204-nerfviewer-ffmpeg  /bin/bash  -c "source ~/miniconda3/bin/activate && conda init bash && conda activate gspl  && cd /root/code && python viewer.py  /root/data/output" 

In Nvidia RTX 2080(6G),I get the error:

Traceback (most recent call last):
  File "/root/code/internal/viewer/client.py", line 121, in run
    self.render_and_send()
  File "/root/code/internal/viewer/client.py", line 92, in render_and_send
    image = self.renderer.get_outputs(camera, scaling_modifier=self.viewer.scaling_modifier.value)
  File "/root/code/internal/viewer/renderer.py", line 18, in get_outputs
    return self.renderer(
  File "/root/miniconda3/envs/gspl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/root/code/internal/renderers/vanilla_renderer.py", line 102, in forward
    rendered_image, radii = rasterizer(
  File "/root/miniconda3/envs/gspl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/root/miniconda3/envs/gspl/lib/python3.9/site-packages/diff_gaussian_rasterization/__init__.py", line 210, in forward
    return rasterize_gaussians(
  File "/root/miniconda3/envs/gspl/lib/python3.9/site-packages/diff_gaussian_rasterization/__init__.py", line 32, in rasterize_gaussians
    return _RasterizeGaussians.apply(
  File "/root/miniconda3/envs/gspl/lib/python3.9/site-packages/torch/autograd/function.py", line 506, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
  File "/root/miniconda3/envs/gspl/lib/python3.9/site-packages/diff_gaussian_rasterization/__init__.py", line 92, in forward
    num_rendered, color, radii, geomBuffer, binningBuffer, imgBuffer = _C.rasterize_gaussians(*args)
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 76.40 GiB (GPU 0; 8.00 GiB total capacity; 365.94 MiB already allocated; 6.55 GiB free; 400.00 MiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

But it could work in Nvidia RTX 4090 (24GB)

yzslab commented 10 months ago

May be 6GB is not enough for your scene. Try to smaller the initial resolution of the web viewer manually here:

https://github.com/yzslab/gaussian-splatting-lightning/blob/8c673b1cdd6df6a3e8231316c6fb47731b9a9b89/viewer.py#L326

https://github.com/yzslab/gaussian-splatting-lightning/blob/8c673b1cdd6df6a3e8231316c6fb47731b9a9b89/viewer.py#L343

svsambandam commented 3 months ago

i also get the same error when running even when setting initial_value as 256: main.py fit --config configs/deformable_blender.yaml --data.path /deformable-data/dnerf/lego I am running on a RTX 3090 with 24GB. Do you know where I might be going wrong :) @yzslab