Giter VIP home page Giter VIP logo

pierotofy / opensplat Goto Github PK

View Code? Open in Web Editor NEW
742.0 22.0 65.0 964 KB

Production-grade 3D gaussian splatting with CPU/GPU support for Windows, Mac and Linux 🚀

Home Page: https://antimatter15.com/splat/?url=https://splat.uav4geo.com/banana.splat

License: GNU Affero General Public License v3.0

CMake 3.51% C++ 47.19% Dockerfile 0.69% Metal 14.53% Objective-C++ 9.43% Cuda 24.28% C 0.37%
3d gaussian radiance-field splats splatting

opensplat's Introduction

💦 OpenSplat

A free and open source implementation of 3D gaussian splatting written in C++, focused on being portable, lean and fast.

OpenSplat takes camera poses + sparse points in COLMAP, OpenSfM, ODM or nerfstudio project format and computes a scene file (.ply or .splat) that can be later imported for viewing, editing and rendering in other software.

Graphics card recommended, but not required! OpenSplat runs the fastest on NVIDIA, AMD and Apple (Metal) GPUs, but can also run entirely on the CPU (~100x slower).

Commercial use allowed and encouraged under the terms of the AGPLv3. ✅

We even have a song 🎵

Getting Started

If you're on Windows, you can buy the pre-built program. This saves you time and helps support the project ❤️. Then jump directly to the run section. As an alternative, check the build section below.

If you're on macOS or Linux check the build section below.

Build

You can build OpenSplat with or without GPU support.

Requirements for all builds:

  • OpenCV: sudo apt install libopencv-dev should do it.
  • libtorch: See instructions below.

CPU

For libtorch visit https://pytorch.org/get-started/locally/ and select your OS, for package select "LibTorch". For compute platform you can select "CPU".

Then:

git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch/ .. && make -j$(nproc)

CUDA

Additional requirement:

For libtorch visit https://pytorch.org/get-started/locally/ and select your OS, for package select "LibTorch". Make sure to match your version of CUDA if you want to leverage GPU support in libtorch.

Then:

git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch/ .. && make -j$(nproc)

ROCm via HIP

Additional requirement:

For libtorch visit https://pytorch.org/get-started/locally/ and select your OS, for package select "LibTorch". Make sure to match your version of ROCm (5.7) if you want to leverage AMD GPU support in libtorch.

Then:

git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat
mkdir build && cd build
export PYTORCH_ROCM_ARCH=gfx906
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch/ -DGPU_RUNTIME="HIP" -DHIP_ROOT_DIR=/opt/rocm -DOPENSPLAT_BUILD_SIMPLE_TRAINER=ON ..
make

In addition, you can leverage Jinja to build the project

cmake -GNinja -DCMAKE_PREFIX_PATH=/path/to/libtorch/ -DGPU_RUNTIME="HIP" -DHIP_ROOT_DIR=/opt/rocm -DOPENSPLAT_BUILD_SIMPLE_TRAINER=ON ..
jinja

Windows

There's several ways to build on Windows, but this particular configuration has been confirmed to work:

Then run:

"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat
md build
cd build
cmake -DCMAKE_PREFIX_PATH=C:/path_to/libtorch_2.1.2_cu11.8/libtorch -DOPENCV_DIR=C:/path_to/OpenCV_4.9.0/build -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

Optional: Edit cuda target (only if required) before cmake --build .

C:/path_to/OpenSplat/build/gsplat.vcxproj for example: arch=compute_75,code=sm_75

macOS

If you're using Homebrew, you can install Cmake/OpenCV/Pytorch by running:

brew install cmake
brew install opencv
brew install pytorch

You will also need to install Xcode and the Xcode command line tools to compile with metal support (otherwise, OpenSplat will build with CPU acceleration only):

  1. Install Xcode from the Apple App Store.
  2. Install the command line tools with xcode-select --install. This might do nothing on your machine.
  3. If xcode-select --print-path prints /Library/Developer/CommandLineTools,then run sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer.

Then run:

git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch/ -DGPU_RUNTIME=MPS .. && make -j$(sysctl -n hw.logicalcpu)
./opensplat

If building CPU-only, remove -DGPU_RUNTIME=MPS.

⚠️ You will probably get a libc10.dylib can’t be opened because Apple cannot check it for malicious software error on first run. Open System Settings and go to Privacy & Security and find the Allow button. You might need to repeat this several times until all torch libraries are loaded.

Docker Build

CUDA

Navigate to the root directory of OpenSplat repo that has Dockerfile and run the following command to build the Docker image:

docker build -t opensplat .

The -t flag and other --build-arg let you tag and further customize your image across different ubuntu versions, CUDA/libtorch stacks, and hardware accelerators. For example, to build an image with Ubuntu 22.04, CUDA 12.1.1, libtorch 2.2.1, and support for CUDA architectures 7.0 and 7.5, run the following command:

docker build \
  -t opensplat:ubuntu-22.04-cuda-12.1.1-torch-2.2.1 \
  --build-arg UBUNTU_VERSION=22.04 \
  --build-arg CUDA_VERSION=12.1.1 \
  --build-arg TORCH_VERSION=2.2.1 \
  --build-arg CMAKE_CUDA_ARCHITECTURES="70;75;80" \
  --build-arg CMAKE_BUILD_TYPE=Release .

ROCm via HIP

Navigate to the root directory of OpenSplat repo that has Dockerfile and run the following command to build the Docker image:

docker build \
  -t opensplat \
  -f Dockerfile.rocm .

The -t flag and other --build-arg let you tag and further customize your image across different ubuntu versions, CUDA/libtorch stacks, and hardware accelerators. For example, to build an image with Ubuntu 22.04, CUDA 12.1.1, libtorch 2.2.1, ROCm 5.7.1, and support for ROCm architectures gfx906, run the following command:

docker build \
  -t opensplat:ubuntu-22.04-cuda-12.1.1-libtorch-2.2.1-rocm-5.7.1-llvm-16 \
  --build-arg UBUNTU_VERSION=22.04 \
  --build-arg CUDA_VERSION=12.1.1 \
  --build-arg TORCH_VERSION=2.2.1 \
  --build-arg ROCM_VERSION=5.7.1 \
  --build-arg PYTORCH_ROCM_ARCH="gfx906" \
  --build-arg CMAKE_BUILD_TYPE=Release .

Note: If you want to use ROCm 6.x, you need to switch to AMD version of pytorch docker as a base layer to build:

docker build \
  -t opensplat:ubuntu-22.04-libtorch-2.1.2-rocm-6.0.2 \
  -f Dockerfile.rocm6 .

Run

To get started, download a dataset and extract it to a folder: [ banana ] [ train ] [ truck ]

Then run from a command line prompt:

Windows

cd c:\path\to\opensplat
opensplat.exe c:\path\to\banana -n 2000

macOS / Linux

cd build
./opensplat /path/to/banana -n 2000

The program will generate an output splat.ply file which can then be dragged and dropped in one of the many viewers such as https://playcanvas.com/viewer. You can also edit/cleanup the scene using https://playcanvas.com/supersplat/editor. The program will also output a cameras.json file in the same directory which can be used by some viewers.

To run on your own data, choose the path to an existing COLMAP, OpenSfM, ODM or nerfstudio project. The project must have sparse points included (random initialization is not supported, see #7).

There's several parameters you can tune. To view the full list:

./opensplat --help

Compression

To generate compressed splats (.splat files), use the -o option:

./opensplat /path/to/banana -o banana.splat

AMD GPU Notes

To train a model with AMD GPU using docker container, you can use the following command as a reference:

  1. Launch the docker container with the following command:
docker run -it -v ~/data:/data --device=/dev/kfd --device=/dev/dri opensplat:ubuntu-22.04-libtorch-2.1.2-rocm-6.0.2 bash
  1. Inside the docker container, run the following command to train the model:
export HIP_VISIBLE_DEVICES=0
export HSA_OVERRIDE_GFX_VERSION=10.3.0  # AMD RX 6700 XT workaround 
cd /code/build
./opensplat /data/banana -n 2000

Project Goals

We recently released OpenSplat, so there's lots of work to do.

  • Support for running on AMD cards (more testing needed)
  • Improve speed / reduce memory usage
  • Distributed computation using multiple machines
  • Real-time training viewer output
  • Automatic filtering
  • Your ideas?

https://github.com/pierotofy/OpenSplat/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement

Contributing

We welcome contributions! Pull requests are welcome.

GPU Memory Notes

A single gaussian takes ~2000 bytes of memory, so currenly you need ~2GB of GPU memory for each million gaussians.

Credits

The methods used in OpenSplat are originally based on splatfacto.

License

The code in this repository, unless otherwise noted, is licensed under the AGPLv3.

The code from splatfacto is originally licensed under the Apache 2.0 license and is © 2023 The Nerfstudio Team.

opensplat's People

Contributors

andrewkchan avatar disa-kizonda avatar ichsan2895 avatar jcaesar avatar jonathan-gore avatar lanxinger avatar pfxuan avatar pierotofy avatar salovision avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opensplat's Issues

how can we train the "train" dataset

hi, i test the banana dataset, but how can we test the "train" dataset, 30K iterations seems do not work well. can you give me some suggestions?

Add benchmarks for speed

It would be a good idea to have some benchmarks around the training time / size of outputted splats in the README, for some GPU / CPU.

SIGSEGV segmentation fault with glibc in OpenSplat

I got this out of gdb, always happens during images:
Thread 1 "opensplat" received signal SIGSEGV, Segmentation fault.
__memmove_evex_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:317
317 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.

Runtime error: element 0 of tensors does not require grad and does not have a grad_fn

Ubuntu 22.04 container in podman (Fedora host)

ROCm version amdgpu-install_5.7.50703-1_all.de

libtorch version libtorch-cxx11-abi-shared-with-deps-2.2.1+rocm5.7.zip

rocminfo reports CPU at 0 and GPU at 1

*******                  
Agent 2                  
*******                  
  Name:                    gfx1103                            
  Uuid:                    GPU-XX                             
  Marketing Name:          AMD Radeon Graphics                
  Vendor Name:             AMD                                
  Feature:                 KERNEL_DISPATCH                    
  Profile:                 BASE_PROFILE                       
  Float Round Mode:        NEAR                               
  Max Queue Number:        128(0x80)                          
  Queue Min Size:          64(0x40)                           
  Queue Max Size:          131072(0x20000)                    
  Queue Type:              MULTI                              
  Node:                    1                                  
  Device Type:             GPU                                
  Cache Info:              
    L1:                      32(0x20) KB                        
    L2:                      2048(0x800) KB                     
  Chip ID:                 5567(0x15bf)                       
  ASIC Revision:           7(0x7)                             
  Cacheline Size:          64(0x40)                           
  Max Clock Freq. (MHz):   2700                               
  BDFID:                   2304                               
  Internal Node ID:        1                                  
  Compute Unit:            12                                 
  SIMDs per CU:            2                                  
  Shader Engines:          1                                  
  Shader Arrs. per Eng.:   2                                  
  WatchPts on Addr. Ranges:4                                  
  Features:                KERNEL_DISPATCH 
  Fast F16 Operation:      TRUE                               
  Wavefront Size:          32(0x20)                           
  Workgroup Max Size:      1024(0x400)                        
  Workgroup Max Size per Dimension:
    x                        1024(0x400)                        
    y                        1024(0x400)                        
    z                        1024(0x400)                        
  Max Waves Per CU:        32(0x20)                           
  Max Work-item Per CU:    1024(0x400)                        
  Grid Max Size:           4294967295(0xffffffff)             
  Grid Max Size per Dimension:
    x                        4294967295(0xffffffff)             
    y                        4294967295(0xffffffff)             
    z                        4294967295(0xffffffff)             
  Max fbarriers/Workgrp:   32                                 
  Packet Processor uCode:: 35                                 
  SDMA engine uCode::      16                                 
  IOMMU Support::          None                               
  Pool Info:               
    Pool 1                   
      Segment:                 GLOBAL; FLAGS: COARSE GRAINED      
      Size:                    1048576(0x100000) KB               
      Allocatable:             TRUE                               
      Alloc Granule:           4KB                                
      Alloc Alignment:         4KB                                
      Accessible by all:       FALSE                              
    Pool 2                   
      Segment:                 GLOBAL; FLAGS:                     
      Size:                    1048576(0x100000) KB               
      Allocatable:             TRUE                               
      Alloc Granule:           4KB                                
      Alloc Alignment:         4KB                                
      Accessible by all:       FALSE                              
    Pool 3                   
      Segment:                 GROUP                              
      Size:                    64(0x40) KB                        
      Allocatable:             FALSE                              
      Alloc Granule:           0KB                                
      Alloc Alignment:         0KB                                
      Accessible by all:       FALSE                              
  ISA Info:                
    ISA 1                    
      Name:                    amdgcn-amd-amdhsa--gfx1103         
      Machine Models:          HSA_MACHINE_MODEL_LARGE            
      Profiles:                HSA_PROFILE_BASE                   
      Default Rounding Mode:   NEAR                               
      Default Rounding Mode:   NEAR                               
      Fast f16:                TRUE                               
      Workgroup Max Size:      1024(0x400)                        
      Workgroup Max Size per Dimension:
        x                        1024(0x400)                        
        y                        1024(0x400)                        
        z                        1024(0x400)                        
      Grid Max Size:           4294967295(0xffffffff)             
      Grid Max Size per Dimension:
        x                        4294967295(0xffffffff)             
        y                        4294967295(0xffffffff)             
        z                        4294967295(0xffffffff)             
      FBarrier Max Size:       32                   

Set these variables accordingly

HIP_VISIBLE_DEVICES=1
ROCM_PATH=/opt/rocm

Trying to run the example bananna set I get this (Claims to be using the CPU??)

📦[parker@ROCm build]$ ./opensplat banana/ -n 2000
Using CPU
Reading 14241 points
[W Cross.cpp:63] Warning: 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. (function operator())
Loading banana/images/frame_00001.JPG
Loading banana/images/frame_00002.JPG
Loading banana/images/frame_00003.JPG
Loading banana/images/frame_00004.JPG
Loading banana/images/frame_00005.JPG
Loading banana/images/frame_00006.JPG
Loading banana/images/frame_00008.JPG
Loading banana/images/frame_00009.JPG
Loading banana/images/frame_00010.JPG
Loading banana/images/frame_00011.JPG
Loading banana/images/frame_00013.JPG
Loading banana/images/frame_00014.JPG
Loading banana/images/frame_00015.JPG
Loading banana/images/frame_00016.JPG
element 0 of tensors does not require grad and does not have a grad_fn
Exception raised from run_backward at ../torch/csrc/autograd/autograd.cpp:105 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6c (0x7f0ad88d2c9c in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0xfa (0x7f0ad887ca5c in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libc10.so)
frame #2: <unknown function> + 0x52b016a (0x7f0ac3eb016a in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #3: torch::autograd::backward(std::vector<at::Tensor, std::allocator<at::Tensor> > const&, std::vector<at::Tensor, std::allocator<at::Tensor> > const&, std::optional<bool>, bool, std::vector<at::Tensor, std::allocator<at::Tensor> > const&) + 0x6a (0x7f0ac3eb2b8a in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #4: <unknown function> + 0x531dbd6 (0x7f0ac3f1dbd6 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #5: at::Tensor::_backward(c10::ArrayRef<at::Tensor>, std::optional<at::Tensor> const&, std::optional<bool>, bool) const + 0x4c (0x7f0ac05f71cc in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #6: ./opensplat() [0x27b536]
frame #7: <unknown function> + 0x29d90 (0x7f0a8b937d90 in /lib/x86_64-linux-gnu/libc.so.6)
frame #8: __libc_start_main + 0x80 (0x7f0a8b937e40 in /lib/x86_64-linux-gnu/libc.so.6)
frame #9: ./opensplat() [0x247a45]

If I run with HIP devices 0 to go to the CPU I get a completely different error

Loading banana/images/frame_00016.JPG
HIP error: invalid device function
HIP kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing HIP_LAUNCH_BLOCKING=1.
Compile with `TORCH_USE_HIP_DSA` to enable device-side assertions.

Exception raised from c10_hip_check_implementation at ../c10/hip/HIPException.cpp:45 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6c (0x7f2ff80f1c9c in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0xfa (0x7f2ff809ba5c in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libc10.so)
frame #2: c10::hip::c10_hip_check_implementation(int, char const*, char const*, int, bool) + 0x3cc (0x7f2fa177fc7c in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libc10_hip.so)
frame #3: void at::native::gpu_kernel_impl<at::native::FillFunctor<float> >(at::TensorIteratorBase&, at::native::FillFunctor<float> const&) + 0x275 (0x7f2fac7e8e75 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_hip.so)
frame #4: at::native::fill_kernel_cuda(at::TensorIterator&, c10::Scalar const&) + 0x222 (0x7f2fac7e27e2 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_hip.so)
frame #5: <unknown function> + 0x1c50b8d (0x7f2fe0050b8d in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #6: <unknown function> + 0x18af403 (0x7f2fad6af403 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_hip.so)
frame #7: at::_ops::fill__Scalar::call(at::Tensor&, c10::Scalar const&) + 0x140 (0x7f2fe08d25c0 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #8: at::native::zero_(at::Tensor&) + 0xbf (0x7f2fe005134f in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #9: <unknown function> + 0x18acb6b (0x7f2fad6acb6b in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_hip.so)
frame #10: at::_ops::zero_::call(at::Tensor&) + 0x13d (0x7f2fe0dfda6d in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #11: at::native::zeros_symint(c10::ArrayRef<c10::SymInt>, std::optional<c10::ScalarType>, std::optional<c10::Layout>, std::optional<c10::Device>, std::optional<bool>) + 0x118 (0x7f2fe0337128 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #12: <unknown function> + 0x2e43299 (0x7f2fe1243299 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #13: at::_ops::zeros::redispatch(c10::DispatchKeySet, c10::ArrayRef<c10::SymInt>, std::optional<c10::ScalarType>, std::optional<c10::Layout>, std::optional<c10::Device>, std::optional<bool>) + 0xf6 (0x7f2fe088a3a6 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #14: <unknown function> + 0x2c139c9 (0x7f2fe10139c9 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #15: at::_ops::zeros::call(c10::ArrayRef<c10::SymInt>, std::optional<c10::ScalarType>, std::optional<c10::Layout>, std::optional<c10::Device>, std::optional<bool>) + 0x1b2 (0x7f2fe08ebd52 in /home/parker/build/OpenSplat/build/torch/libtorch/lib/libtorch_cpu.so)
frame #16: ./opensplat() [0x25c01e]
frame #17: ./opensplat() [0x27b07e]
frame #18: <unknown function> + 0x29d90 (0x7f2fab137d90 in /lib/x86_64-linux-gnu/libc.so.6)
frame #19: __libc_start_main + 0x80 (0x7f2fab137e40 in /lib/x86_64-linux-gnu/libc.so.6)
frame #20: ./opensplat() [0x247a45]

Problem with using COLMAP project

Using datasets from here #1 (comment) I got no problem using OpenSplat.
But when I make my own point cloud in COLMAP (using banana images from example datasets) and then run them in OpenSplat i get an error "Unsupported camera model: 2". What can cause that?
I'm using COLMAP-3.9.1-windows-cuda with GUI and "automatic reconstruction" function, if that's important.

SfM-Free Support

Current 3DGS training pipeline is heavily relying on the SfM initialization, which introduces a significant overhead when scaling to large scenes. Technically, 3DGS should be capable of producing relevantly good results with a randomly or strategically initialized point cloud:

While waiting for the release of COLMAP-Free 3DGS codebase, RAIN-GS appears to offer a similar or potentially simpler solution for decoupling the SfM step. This involves sparse-large-variance (SLV) initialization along with progressive gaussian low-pass filter control.

Maintain scene orientation

Hello again! I'm now having a great time processing my own data with OpenSplat! Very smooth sailing so far.

Question. I have a known scene orientation (in Colmap) that I would like to preserve if possible, but the training results are coming out in at a different location/scale. Is there an option to maintain the input orientation?

Thanks again!

Enable MPS backend

I was able to run through MacOS arm-64 build using M2 max chip. But it's very slow. It would be great if we can make MPS backend work. I started a quick test from this branch. But it seems like there is a memory allocation problem.

cd build
cmake -DCMAKE_PREFIX_PATH=/Users/pxuan/Projects/torch/libtorch -DGPU_RUNTIME=MPS ../

undefined reference

@pierotofy
Hi, When I compile the program, the following error occurs. My computer environment is ubuntu18.04+cuda10.2+cudnn7:
[100%] Linking CXX executable opensplat CMakeFiles/opensplat.dir/spherical_harmonics.cpp.o: In function ‘SphericalHarmonics::forward(torch::autograd::AutogradContext*, int, at::Tensor, at::Tensor)’: spherical_harmonics.cpp:(.text+0x69c): undefined reference to 'compute_sh_forward_tensor(unsigned int, unsigned int, unsigned int, at::Tensor&, at::Tensor&)' CMakeFiles/opensplat.dir/spherical_harmonics.cpp.o: In function 'SphericalHarmonics::backward(torch::autograd::AutogradContext*, std::vector<at::Tensor, std::allocator<at::Tensor>> in)' in: spherical_harmonics.cpp:(.text+0xec4): undefined reference to 'compute_sh_backward_tensor(unsigned int, unsigned int, unsigned int, at::Tensor&, at::Tensor&)' CMakeFiles/opensplat.dir/project_gaussians.cpp.o: In function 'ProjectGaussians::forward(torch::autograd::AutogradContext*, at::Tensor, at::Tensor, float, at::Tensor, at::Tensor , at::Tensor, float, float, float, float, int, int, std::tuple<int, int, int>, float)': project_gaussians.cpp:(.text+0x137): For 'project_gaussians_forward_tensor(int, at::Tensor&, at::Tensor&, float, at::Tensor&, at::Tensor&, at::Tensor&, float, float, float, float, unsigned int, unsigned int, std::tuple<int, int, int>, float)' undefined reference

fatal error: json.hpp: No such file or directory 2 | #include <json.hpp>

I got error when building it

git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat/
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/workspace/OPENSPLAT/libtorch .. && make -j$(nproc)

image

Using Runpod environment with this specification

Ubuntu 22.04 LTS
Python 3.10
libtorch 2.0.1+cu118
RTX A6000 with 48 GB VRAM

Docker build

Would be cool to get automated docker builds (and CI tests)

Add option to limit number of gaussians

A single gaussian takes ~2000 bytes of memory, so currenly one needs ~1GB of GPU memory for each million gaussians.

We should have an option to limit the number of gaussians (ideally by detecting automatically the memory available).

Add MSL support

Metal could be a good candidate for getting faster training on Mac.

element 0 of tensors does not require grad and does not have a grad_fn

it runs fine on the example datasets, i aligned with metashape, converted to nerfstudio with ns-process-data and exported a pointcloud/tiepoints in local coordinate system(i also tried mercator(epsg:3395) ply export) and added "ply_file_path": "spc.ply" to the json

windows 11
cuda 11.8
OpenSplat v1.1.2
Visual Studio 2022
libtorch 2.2.2 because recommended libtorch 2.1.2 didn't want to compile
cmake 3.28.3
opencv 4.9.0
dual gpu sli 2080 ti
all images were 4000x3000

build log:

-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.31.31104.0
-- The CXX compiler identification is MSVC 19.31.31104.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/include (found version "11.8.89")
-- The CUDA compiler identification is NVIDIA 11.8.89
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/bin/nvcc.exe - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8 (found version "11.8")
-- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/include (found version "11.8.89")
-- Caffe2: CUDA detected: 11.8
-- Caffe2: CUDA nvcc is: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/bin/nvcc.exe
-- Caffe2: CUDA toolkit directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8
-- Caffe2: Header version is: 11.8
-- C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/lib/x64/nvrtc.lib shorthash is dd482e34
-- USE_CUDNN is set to 0. Compiling without cuDNN support
-- USE_CUSPARSELT is set to 0. Compiling without cuSPARSELt support
-- Autodetected CUDA architecture(s):  7.5 7.5
-- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75
-- Found Torch: E:/Git/OpenSplat/libtorch/lib/torch.lib
-- OpenCV ARCH: x64
-- OpenCV RUNTIME: vc16
-- OpenCV STATIC: OFF
-- Found OpenCV: E:/Git/OpenSplat/opencv/build (found version "4.9.0")
-- Found OpenCV 4.9.0 in E:/Git/OpenSplat/opencv/build/x64/vc16/lib
-- You might need to add E:\Git\OpenSplat\opencv\build\x64\vc16\bin to your PATH to be able to run your applications.
-- Configuring done (19.7s)
-- Generating done (0.1s)
-- Build files have been written to: E:/Git/OpenSplat/build

cmake --build . --config Release went fine, there were plenty of type conversion warnings but nothing else

here's my run:

Using CUDA
Reading 29939 points
Loading nsproj\images/frame_00001.jpg
Loading nsproj\images/frame_00002.jpg
Loading nsproj\images/frame_00003.jpg
Loading nsproj\images/frame_00004.jpg
Loading nsproj\images/frame_00005.jpg
Loading nsproj\images/frame_00006.jpg
Loading nsproj\images/frame_00007.jpg
Loading nsproj\images/frame_00008.jpg
Loading nsproj\images/frame_00009.jpg
Loading nsproj\images/frame_00010.jpg
Loading nsproj\images/frame_00011.jpg
Loading nsproj\images/frame_00012.jpg
Loading nsproj\images/frame_00013.jpg
Loading nsproj\images/frame_00014.jpg
Loading nsproj\images/frame_00015.jpg
Loading nsproj\images/frame_00016.jpg
Loading nsproj\images/frame_00017.jpg
Loading nsproj\images/frame_00018.jpg
Loading nsproj\images/frame_00019.jpg
Loading nsproj\images/frame_00020.jpg
Loading nsproj\images/frame_00021.jpg
Loading nsproj\images/frame_00022.jpg
Loading nsproj\images/frame_00023.jpg
Loading nsproj\images/frame_00024.jpg
Loading nsproj\images/frame_00025.jpg
Loading nsproj\images/frame_00026.jpg
Loading nsproj\images/frame_00027.jpg
Loading nsproj\images/frame_00028.jpg
Loading nsproj\images/frame_00029.jpg
Loading nsproj\images/frame_00030.jpg
Loading nsproj\images/frame_00031.jpg
Loading nsproj\images/frame_00032.jpg
Loading nsproj\images/frame_00033.jpg
Loading nsproj\images/frame_00034.jpg
Loading nsproj\images/frame_00035.jpg
Loading nsproj\images/frame_00036.jpg
element 0 of tensors does not require grad and does not have a grad_fn
Exception raised from run_backward at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\autograd\autograd.cpp:109 (most recent call first):
00007FF98162AF4200007FF98162AEE0 c10.dll!c10::Error::Error [<unknown file> @ <unknown line number>]
00007FF98162AACA00007FF98162AA70 c10.dll!c10::detail::torchCheckFail [<unknown file> @ <unknown line number>]
00007FF8894E13F600007FF8894E1170 torch_cpu.dll!torch::autograd::grad [<unknown file> @ <unknown line number>]
00007FF8894E106A00007FF8894E1000 torch_cpu.dll!torch::autograd::backward [<unknown file> @ <unknown line number>]
00007FF88952014100007FF88951D730 torch_cpu.dll!torch::autograd::SavedVariable::unpack [<unknown file> @ <unknown line number>]
00007FF886B1815400007FF886B18100 torch_cpu.dll!at::Tensor::_backward [<unknown file> @ <unknown line number>]
00007FF886930CB000007FF886930C30 torch_cpu.dll!at::Tensor::backward [<unknown file> @ <unknown line number>]
00007FF716C0FF3100007FF716C0CA60 opensplat.exe!c10::ivalue::Future::waitAndThrow [<unknown file> @ <unknown line number>]
00007FF716C6FEE000007FF716C0CA60 opensplat.exe!c10::ivalue::Future::waitAndThrow [<unknown file> @ <unknown line number>]
00007FF9E1D5257D00007FF9E1D52560 KERNEL32.DLL!BaseThreadInitThunk [<unknown file> @ <unknown line number>]
00007FF9E352AA4800007FF9E352AA20 ntdll.dll!RtlUserThreadStart [<unknown file> @ <unknown line number>]```

A way to continue training

Considering that this program can use CPU and low VRam cards to train, how about adding a way or parameter to continue training from saved splat.ply? Is this even feasible?

compiler error linux (ubuntu 22.04 / gcc11 / cuda 11.8)

"parameter packs not expanded with" error using gcc 11.4.0 on ubuntu 22.04 x86_64

[  4%] Building CUDA object CMakeFiles/gsplat.dir/vendor/gsplat/forward.cu.o
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
  435 |         function(_Functor&& __f)
      |                                                                                                                                                 ^ 
/usr/include/c++/11/bits/std_function.h:435:145: note:         ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
  530 |         operator=(_Functor&& __f)
      |                                                                                                                                                  ^ 
/usr/include/c++/11/bits/std_function.h:530:146: note:         ‘_ArgTypes’

This loos like a C++20 feature. Please update docs if there is a recommended compiler configuration known to work (clang or more bleeding edge compiler on linux). If this is misconfiguration it doesn't seem obvious regarding a possible misstep.

Support for rendering video

Interpolating the camera poses, choosing target resolution and FPS, automatically create a video from a scene + poses.

specific version of LibTorch

Do you have any specification of the version of LibTorch?

Just encounter a bug "rror: ‘to_string’ is not a member of ‘c10::guts’" while using it with libtorch 2.2.0

CPU support

It should be possible to port the rasterizer to CPU (maybe via HIP), or simply rewriting it.

It might be slow, but it would give people the freedom to run this stuff without the NVIDIA tax.

Speed up CPU code

There are several parts that could be optimized:

  • Implement multi-threading
  • Benchmark and eventually port the project/compute_sh functions from libtorch to pure C++ (will need to manually write the backward pass)
  • Profile and identify bottlenecks

2d image mask support

Hello, and congratulations on your awesome work! Now that you've added Colmap support, I'm really excited to dive in.

Question, do you plan to support 2d image masks? These would be used to ignore specific regions of the image during training.

Thanks so much!

Hard-coded OS version in .github/workflows/cuda/Linux.sh

Hi, note that the Ubuntu version passed as --build-arg in the Dockerfile is not propagated to .github/workflows/cuda/Linux.sh:

I'm not sure that this is a bug, but surely it would be nice to be consistent. Also, at least for Ubuntu 18.04 and CUDA 11.3, cuDNN is not installed and libtorch fails to build later. Again, I'm not sure that these two things are related. Will update if I have news.

Thanks for your work anyway :)

[Enchancement] A bug in original Gsplat. Maybe it also happen in this implementation

Today, I have read discord that gsplat & nerfstudio has a big bugs. After it fixed, it being said that the quality is increasing.

The bug is about The calculation of cov2d's grad is incorrect and the unit test doesn't report errors because the test cases are too weak:
nerfstudio-project/gsplat#136

It claims the fixing will be increasing the quality of reconstruction. Here is the discord link:
https://discord.com/channels/1025504971606724712/1167872346707738664/1212867101585571850

compile error, which version of libtorch should i use?

OpenSplat/model.cpp:199:35: error: no matching function for call to ‘cat(, int)’
199 | paramState->exp_avg(torch::cat({
| ~~~~~~~~~~^~
200 | paramState->exp_avg(),
| ~~~~~~~~~~~~~~~~~~~~~~
201 | torch::zeros_like(paramState->exp_avg().index({idcs.squeeze()})).repeat(repeats)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202 | }, 0));
| ~~~~~

OpenSplat/model.cpp:386:35: error: ‘to_string’ is not a member of ‘c10::guts’
386 | auto pId = c10::guts::to_string(param.unsafeGetTensorImpl());

Remove floaters

There should be a way to reduce/filter floaters.

image

These significantly reduce the quality of visualization.

I thought about doing a nearest neighbor search from of the splat means compared to the points in the initial point cloud and filter any splat that is not within X units of an original point. But I don't know if this would work, as certain areas could have no initialization points. If there are better/proven methods I'd like to hear it.

Add measurements to Splat

I think I may be misunderstanding what Gaussian Splats exactly are.

But is there any way to add the ability to set reference dimensions so we could derive measurements from Gaussian Splat files?

Add ability to test training accuracy

  • Withhold a single camera C from the iteration process (random or user-specified)
  • Run training
  • Render the model from C
  • Compare ground truth to render

It should help observe whether changes improve or degrade results.

Installation issues

Hello! Working through the installation on a CUDA machine and WSL/Ubuntu 2204.3 on WIndows 11 and getting tripped up during the cmake command in the readme.

I followed the Build (CUDA) steps in the readme, ending here with the last command:

(opensplat) proclocal@PROC66:/mnt/c/Users/PROCLOCAL/Documents/github/opensplat/build$ cmake -DCMAKE_PREFIX_PATH=$PWD/libtorch ..  && make -j$(nproc)
-- Found CUDAToolkit: /usr/include (found version "11.5.119")
-- Found CUDAToolkit: /usr/include (found version "11.5.119")
-- Caffe2: CUDA detected: 11.5
-- Caffe2: CUDA nvcc is: /usr/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr
-- Caffe2: Header version is: 11.5
-- /usr/lib/x86_64-linux-gnu/libnvrtc.so shorthash is 65f2c18b
-- USE_CUDNN is set to 0. Compiling without cuDNN support
-- USE_CUSPARSELT is set to 0. Compiling without cuSPARSELt support
-- Autodetected CUDA architecture(s):  7.5 7.5
-- Added CUDA NVCC flags for: -gencode;arch=compute_75,code=sm_75
CMake Warning at /mnt/c/Users/PROCLOCAL/Documents/GitHub/OpenSplat/build/libtorch/share/cmake/Torch/TorchConfig.cmake:22 (message):
  static library c10_LIBRARY-NOTFOUND not found.
Call Stack (most recent call first):
  /mnt/c/Users/PROCLOCAL/Documents/GitHub/OpenSplat/build/libtorch/share/cmake/Torch/TorchConfig.cmake:70 (append_torchlib_if_found)
  CMakeLists.txt:51 (find_package)


CMake Warning at /mnt/c/Users/PROCLOCAL/Documents/GitHub/OpenSplat/build/libtorch/share/cmake/Torch/TorchConfig.cmake:22 (message):
  static library kineto_LIBRARY-NOTFOUND not found.
Call Stack (most recent call first):
  /mnt/c/Users/PROCLOCAL/Documents/GitHub/OpenSplat/build/libtorch/share/cmake/Torch/TorchConfig.cmake:127 (append_torchlib_if_found)
  CMakeLists.txt:51 (find_package)

CMake Error at /snap/cmake/1366/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Torch (missing: TORCH_LIBRARY)
Call Stack (most recent call first):
  /snap/cmake/1366/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /mnt/c/Users/PROCLOCAL/Documents/GitHub/OpenSplat/build/libtorch/share/cmake/Torch/TorchConfig.cmake:190 (find_package_handle_standard_args)
  CMakeLists.txt:51 (find_package)


-- Configuring incomplete, errors occurred!

Any insight?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.