buaacyw / GaussianEditor

[CVPR 2024] GaussianEditor: Swift and Controllable 3D Editing with Gaussian Splatting
https://buaacyw.github.io/gaussian-editor/
Other
1.13k stars 57 forks source link

expect scalar Float type but input BFloat16 #78

Open 5p6 opened 1 day ago

5p6 commented 1 day ago

1.Environment

2. Error Report

I download the bear dataset,and it dir like

- <datadir>
    - images  
       - frame_00001.jpg
       - ....
    - sparse
       - 0 
          - points3D.ply
          - points3D.bin
          - cameras.bin
          - images.bin
    - bear.ply 

and i run webui.py like this

python3 webui.py \
    --colmap_dir <datadir>/ \
    --gs_source <datadir>/bear.ply

and then it will report an error ,which said the expect type is float but input with BFloat16.

/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/controlnet_aux/mediapipe_face/mediapipe_face_common.py:7: UserWarning: The module 'mediapipe' is not installed. The package will have limited functionality. Please install it using the command: pip install 'mediapipe'
  warnings.warn(
/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/sam2/modeling/sam/transformer.py:23: UserWarning: Flash Attention is disabled as it requires a GPU with Ampere (8.0) CUDA capability.
  OLD_GPU, USE_FLASH_ATTN, MATH_KERNEL_ON = get_sdpa_settings()
Reading camera 96/96

/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/utils/cpp_extension.py:1967: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. 
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
  warnings.warn(
╭─────────────── viser ───────────────╮
│             ╷                       │
│   HTTP      │ http://0.0.0.0:8084   │
│   Websocket │ ws://0.0.0.0:8084     │
│             ╵                       │
╰─────────────────────────────────────╯
(viser) Connection opened (0, 1 total), 186 persistent messages
Reading camera 96/96
Traceback (most recent call last):
  File "/home/ros/code/GaussianEditor/webui.py", line 1570, in <module>
    webui.render_loop()
  File "/home/ros/code/GaussianEditor/webui.py", line 1025, in render_loop
    self.update_viewer()
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/webui.py", line 1033, in update_viewer
    output = self.render(gs_camera, sam=self.sam_enabled.value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/webui.py", line 693, in render
    render_pkg = render(cam, self.gaussian, self.pipe, self.background_tensor)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/gaussian_renderer/__init__.py", line 131, in render
    rendered_image, radii, depth = rasterizer(
                                   ^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/submodules/origin-diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 210, in forward
    return rasterize_gaussians(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/submodules/origin-diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 32, in rasterize_gaussians
    return _RasterizeGaussians.apply(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/autograd/function.py", line 598, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 92, in forward
    num_rendered, color, radii, geomBuffer, binningBuffer, imgBuffer = _C.rasterize_gaussians(*args)
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: expected scalar type Float but found BFloat16
5p6 commented 1 day ago

1.Environment

  • WSL2 Ubuntu 22.04
  • python3.11
  • cuda12.1
  • torch 2.3.0 cu121
  • torchvision 0.18.0 cu121

2. Error Report

I download the bear dataset,and it dir like

- <datadir>
    - images  
       - frame_00001.jpg
       - ....
    - sparse
       - 0 
          - points3D.ply
          - points3D.bin
          - cameras.bin
          - images.bin
    - bear.ply 

and i run webui.py like this

python3 webui.py \
    --colmap_dir <datadir>/ \
    --gs_source <datadir>/bear.ply

and then it will report an error ,which said the expect type is float but input with BFloat16.

/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/controlnet_aux/mediapipe_face/mediapipe_face_common.py:7: UserWarning: The module 'mediapipe' is not installed. The package will have limited functionality. Please install it using the command: pip install 'mediapipe'
  warnings.warn(
/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/sam2/modeling/sam/transformer.py:23: UserWarning: Flash Attention is disabled as it requires a GPU with Ampere (8.0) CUDA capability.
  OLD_GPU, USE_FLASH_ATTN, MATH_KERNEL_ON = get_sdpa_settings()
Reading camera 96/96

/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/utils/cpp_extension.py:1967: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. 
If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST'].
  warnings.warn(
╭─────────────── viser ───────────────╮
│             ╷                       │
│   HTTP      │ http://0.0.0.0:8084   │
│   Websocket │ ws://0.0.0.0:8084     │
│             ╵                       │
╰─────────────────────────────────────╯
(viser) Connection opened (0, 1 total), 186 persistent messages
Reading camera 96/96
Traceback (most recent call last):
  File "/home/ros/code/GaussianEditor/webui.py", line 1570, in <module>
    webui.render_loop()
  File "/home/ros/code/GaussianEditor/webui.py", line 1025, in render_loop
    self.update_viewer()
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/webui.py", line 1033, in update_viewer
    output = self.render(gs_camera, sam=self.sam_enabled.value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/webui.py", line 693, in render
    render_pkg = render(cam, self.gaussian, self.pipe, self.background_tensor)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/gaussian_renderer/__init__.py", line 131, in render
    rendered_image, radii, depth = rasterizer(
                                   ^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1532, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1541, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 210, in forward
    return rasterize_gaussians(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/submodules/origin-diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 32, in rasterize_gaussians
    return _RasterizeGaussians.apply(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gseditor/lib/python3.11/site-packages/torch/autograd/function.py", line 598, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ros/code/GaussianEditor/gaussiansplatting/submodules/origin-diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 92, in forward
    num_rendered, color, radii, geomBuffer, binningBuffer, imgBuffer = _C.rasterize_gaussians(*args)
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: expected scalar type Float but found BFloat16

I solved this problem,I detect the error was in /home/ros/code/GaussianEditor/gaussiansplatting/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py,so i check the args parameters type,like

        for arg in args:
            print(type(arg))
            if type(arg)==torch.Tensor:
                print(arg.dtype)

and it report the value raster_settings.projmatrix's type is BFloat16,so i change it type mannuel at GaussianEditor/gaussiansplatting/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/init.py between 65 row and 85 row ,change the code block like this

        args = (
            raster_settings.bg,
            means3D,
            colors_precomp,
            opacities,
            scales,
            rotations,
            raster_settings.scale_modifier,
            cov3Ds_precomp,
            raster_settings.viewmatrix,
            raster_settings.projmatrix.to(torch.float32).to("cuda:0"), # pay attention here
            raster_settings.tanfovx,
            raster_settings.tanfovy,
            raster_settings.image_height,
            raster_settings.image_width,
            sh,
            raster_settings.sh_degree,
            raster_settings.campos,
            raster_settings.prefiltered,
            raster_settings.debug,
        )

then run the command ,it will work