A free and open source implementation of 3D gaussian splatting written in C++, focused on being portable, lean and fast.
![](https://private-user-images.githubusercontent.com/1951843/314984262-c9327c7c-31ad-402d-a5a5-04f7602ca5f5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4ODIzOTQsIm5iZiI6MTcyMzg4MjA5NCwicGF0aCI6Ii8xOTUxODQzLzMxNDk4NDI2Mi1jOTMyN2M3Yy0zMWFkLTQwMmQtYTVhNS0wNGY3NjAyY2E1ZjUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTdUMDgwODE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mjg1ZTNlNGMwMThhZGM5ZTk4ZGVjYjk0NmY2YTU5ZDQ4MzY1ODRjZjFmODk1OWM5NjQyZjAxMmQxMTY2NmRkYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.dwupksOBIbX1lNma6AR-RqaUPDu1274cfO-R7JGMB4s)
![](https://private-user-images.githubusercontent.com/1951843/314667230-eba4ae75-2c88-4c9e-a66b-608b574d085f.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4ODIzOTQsIm5iZiI6MTcyMzg4MjA5NCwicGF0aCI6Ii8xOTUxODQzLzMxNDY2NzIzMC1lYmE0YWU3NS0yYzg4LTRjOWUtYTY2Yi02MDhiNTc0ZDA4NWYuZ2lmP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MTdUMDgwODE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTAxMDgwMWE4MDk2M2IxYmFkYTA3NmY1ZjkzYWE5YWIwMzlmNDAyMWQ2ZjZjYmU5NGQwNGU1YWUyNWJkZGQ0ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.YOEziHs0e0aokNVNHW9FwQM9pcDv0hALVJVDoVoQOYQ)
OpenSplat takes camera poses + sparse points in COLMAP or nerfstudio project format and computes a scene file (.ply) 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 and AMD GPUs, but can also run entirely on the CPU (~100x slower).
Commercial use allowed and encouraged under the terms of the AGPLv3. β
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.
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)
Additional requirement:
- CUDA: Make sure you have the CUDA compiler (
nvcc
) in your PATH and thatnvidia-smi
is working. https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
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)
Additional requirement:
- ROCm: Make sure you have the ROCm installed at /opt/rocm. https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html
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
There's several ways to build on Windows, but this particular configuration has been confirmed to work:
- Visual Studio 2022 C++
- https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-windows-x86_64.msi
- https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe
- https://download.pytorch.org/libtorch/cu118/libtorch-win-shared-with-deps-2.1.2%2Bcu118.zip
- https://github.com/opencv/opencv/releases/download/4.9.0/opencv-4.9.0-windows.exe
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
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=C:/path_to/libtorch_2.1.2_cu11.8 -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
If you're using Homebrew, you can install Cmake/OpenCV/Pytorch by running:
brew install cmake
brew install opencv
brew install pytorch
Then run:
git clone https://github.com/pierotofy/OpenSplat OpenSplat
cd OpenSplat
mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=/path/to/libtorch/ .. && make -j$(nproc)
./opensplat
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 TORCH_CUDA_ARCH_LIST="7.0;7.5" \
--build-arg CMAKE_BUILD_TYPE=Release .
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 .
To get started, download a dataset and extract it to a folder: [ banana ] [ train ] [ truck ]
Then run:
./opensplat /path/to/banana -n 2000
[...]
Wrote splat.ply
The output splat.ply
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
To run on your own data, choose the path to an existing COLMAP or nerfstudio project. The project must have sparse points included (random initialization is not supported, see pierotofy#7).
There's several parameters you can tune. To view the full list:
./opensplat --help
To train a model with AMD GPU using docker container, you can use the following command as a reference:
- 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
- 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
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
- Add Metal support on macOS
- Distributed computation using multiple machines
- Real-time training viewer output
- Compressed scene outputs
- Automatic filtering
- Your ideas?
https://github.com/pierotofy/OpenSplat/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement
We welcome contributions! Pull requests are welcome.
A single gaussian takes ~2000 bytes of memory, so currenly you need ~2GB of GPU memory for each million gaussians.
The methods used in OpenSplat are originally based on splatfacto.
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.