graphdeco-inria / gaussian-splatting

Original reference implementation of "3D Gaussian Splatting for Real-Time Radiance Field Rendering"
https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/
Other
14.53k stars 1.9k forks source link

Ubuntu 24.04 & CUDA 12 Support #923

Open pens opened 3 months ago

pens commented 3 months ago

Apologies as this isn't an issue per se. I just finished getting training and the local viewer working on Ubuntu 24.04 with CUDA 12. As the process was a little involved I hope that sharing the changes needed might be useful.

environment.yml

name: gaussian_splatting
channels:
  - pytorch
  - conda-forge
  - defaults
  - nvidia
dependencies:
  - cuda-toolkit=12.4
  - plyfile
  - python=3.8
  - pip=22.3.1
  - pytorch
  - torchaudio
  - torchvision
  - tqdm
  - pytorch-cuda=12.4
  - pip:
    - submodules/diff-gaussian-rasterization
    - submodules/simple-knn

submodules/simple-knn/simple-knn.cu

The newer NVIDIA headers (seem to) no longer export FLT_MIN & FLT_MAX, so float.h needs to be explicitly included.

simple-knn.patch.txt

SIBR_viewers

Both Embree and FFmpeg have removed parts of their APIs that SIBR was using. I didn't test this with the remote viewer at all, as I was really just trying to get the local viewer building and running.

I updated the FFmpeg part with something that seemed in the right direction, but it's probably broken. I really have no idea if I hit the Embree path or not.

SIBR_viewers.patch.txt

CudaRasterizer

Also probably due to NVIDIA's headers, CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h requires cstdint to be included.

mazy1998 commented 2 months ago

Works like a charm, thanks

Miaoing commented 2 months ago

Thank you very much!!! It saves me for hours of work & debugging.

Pydes-boop commented 2 months ago

Did you encounter any issues with installing simple-knn except for including the float.h header as you mentioned @pens ? I seem unable to get this going on my system currently and im seeing some other discussions around the issues with simple-knn and different cuda versions but cant seem to fix the installation on my side.

Ive looked into these but my system still does not want to finish the install

317 #297 #257

Did you have any additional changes or install specific versions of gcc g++ or anything like that for your setup with wsl?

pens commented 1 month ago

Did you encounter any issues with installing simple-knn except for including the float.h header as you mentioned @pens ? I seem unable to get this going on my system currently and im seeing some other discussions around the issues with simple-knn and different cuda versions but cant seem to fix the installation on my side.

Ive looked into these but my system still does not want to finish the install #317 #297 #257

Did you have any additional changes or install specific versions of gcc g++ or anything like that for your setup with wsl?

To be honest, I don't recall. You mention WSL though, so I should point out that this was done on a bare metal Ubuntu installation. The system itself was more or less a clean install.

aruiplex commented 3 weeks ago

Hi! I am using the patch file you provided. It still has some errors when I compile the SIBR.

This is the way I use the patch file:

# In the directory gaussian-splatting/SIBR_viewers 
patch -p1 < SIBR_viewers.patch.txt

Then I build by using the README way

cmake -Bbuild . -DCMAKE_BUILD_TYPE=Release -G Ninja # add -G Ninja to build faster
cmake --build build --target install --config RelWithDebInfo

Here is the error info, I picked some text.

[36/136] Building CUDA object /<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/build/CMakeFiles/CudaRasterizer.dir/cuda_rasterizer/rasterizer_impl.cu.o
FAILED: /<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/build/CMakeFiles/CudaRasterizer.dir/cuda_rasterizer/rasterizer_impl.cu.o 
/usr/local/cuda-12.6/bin/nvcc -forward-unknown-to-host-compiler -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DEIGEN_INITIALIZE_MATRICES_BY_ZERO -DGLEW_EGL -DOPENCV_TRAITS_ENABLE_DEPRECATED -I/usr/include/eigen3 -I/home/aruix/miniconda3/envs/3d/include -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/imgui -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/imgui/imgui -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/nativefiledialog -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/nativefiledialog/nativefiledialog -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/mrf -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/mrf/mrf -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/nanoflann -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/nanoflann/nanoflann -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/picojson -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/picojson/picojson -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/rapidxml -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/rapidxml/rapidxml -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/xatlas -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/xatlas/xatlas -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/xatlas/xatlas/source/xatlas -I/<my-path>/gaussian-splatting/SIBR_viewers/src/. -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer -I/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/third_party/glm -I/usr/local/cuda-12.6/targets/x86_64-linux/include -O3 -DNDEBUG -std=c++14 "--generate-code=arch=compute_70,code=[compute_70,sm_70]" "--generate-code=arch=compute_75,code=[compute_75,sm_75]" "--generate-code=arch=compute_86,code=[compute_86,sm_86]"   -fpermissive -fPIC -Wall -Wno-unknown-pragmas -Wno-sign-compare -g -std=c++17 -D__forceinline="inline __attribute__((always_inline))" -MD -MT /<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/build/CMakeFiles/CudaRasterizer.dir/cuda_rasterizer/rasterizer_impl.cu.o -MF /<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/build/CMakeFiles/CudaRasterizer.dir/cuda_rasterizer/rasterizer_impl.cu.o.d -x cu -c /<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.cu -o /<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/build/CMakeFiles/CudaRasterizer.dir/cuda_rasterizer/rasterizer_impl.cu.o
nvcc warning : incompatible redefinition for option 'std', the last value of this option was used
/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(24): error: namespace "std" has no member "uintptr_t"
    std::size_t offset = (reinterpret_cast<std::uintptr_t>(chunk) + alignment - 1) & ~(alignment - 1);
                                                ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(40): error: identifier "uint32_t" is undefined
    uint32_t* point_offsets;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(41): error: identifier "uint32_t" is undefined
    uint32_t* tiles_touched;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(49): error: identifier "uint32_t" is undefined
    uint32_t* n_contrib;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(58): error: identifier "uint64_t" is undefined
    uint64_t* point_list_keys_unsorted;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(59): error: identifier "uint64_t" is undefined
    uint64_t* point_list_keys;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(60): error: identifier "uint32_t" is undefined
    uint32_t* point_list_unsorted;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.h(61): error: identifier "uint32_t" is undefined
    uint32_t* point_list;
    ^

/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.cu(188): warning #549-D: variable "binning" is used before its value is set
   obtain(chunk, binning.point_list, P, 128);
                 ^

Remark: The warnings can be suppressed with "-diag-suppress <warning-number>"

8 errors detected in the compilation of "/<my-path>/gaussian-splatting/SIBR_viewers/extlibs/CudaRasterizer/CudaRasterizer/cuda_rasterizer/rasterizer_impl.cu".
arhanjain commented 1 week ago

lifesaver!! :heart_eyes:

pens commented 1 week ago

@aruiplex, that file is missing the necessary include (https://en.cppreference.com/w/cpp/types/integer). Try adding #include <cstdint> to the top of rasterizer_impl.h.

MMMaverick commented 1 week ago

Thank you, you are my God!!!

amiryanj commented 1 day ago

Hey @pens Thanks for sharing this. Did you need to install cuda separately? 12.4 or 12.6? since I see the cuda official download does not propose Cuda12.4 for Ubuntu 24.04. Then it makes some issues for installing the submodule diff-gaussian-rasterization