pierotofy / OpenSplat

Production-grade 3D gaussian splatting with CPU/GPU support for Windows, Mac and Linux 🚀
https://antimatter15.com/splat/?url=https://splat.uav4geo.com/banana.splat
GNU Affero General Public License v3.0
933 stars 87 forks source link

undefined reference #16

Closed yuancaimaiyi closed 9 months ago

yuancaimaiyi commented 9 months ago

@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

pierotofy commented 9 months ago

Strange, does the gsplat target build properly?

make gsplat

Have you made any changes?

yuancaimaiyi commented 9 months ago

@pierotofy
[100%] Built target gsplat I haven't changed anything, but undefined reference appears.

pierotofy commented 9 months ago

Mm, I can't seem to reproduce it on my machine; if you find a way to fix it, please do share?

Maybe it has to do with the compiler/nvcc version.

yuancaimaiyi commented 9 months ago

@pierotofy the latest update: When I use another machine: ubuntu20.04, cudn11.2, cudnn8.1.1, libtorch1.8.0+cu112. The following error appears:

OpenSplat/optim_scheduler.hpp:11:87: error: ‘struct torch::optim::AdamOptions’ has no member named ‘get_lr’
    11 | static_cast<torch::optim::AdamOptions&>(opt->param_groups()[0].options()).get_lr()
OpenSplat/model.cpp:236:46: error: ‘vector_norm’ is not a member of ‘torch::linalg’
   236 | torch::Tensor grads = torch::linalg::vector_norm(xys.grad().detach(), 2, { -1 }, false, torch::kFloat32);

Therefore, I suggest that you provide a dockfile to everyone, because the environment is too difficult to configure.

pierotofy commented 9 months ago

Indeed. There's #12 open (and up for grabs, if you'd like to help with a PR)?

pfxuan commented 9 months ago

@yuancaimaiyi Thank you for taking the time to test it out! This information is super helpful. It seems like vector_norm is a newly introduced method in libtorch 1.9.0 from this PR https://github.com/pytorch/pytorch/issues/50214. There should exist a way to make OpenSplat backward compatible with libtorch 1.8.0.

Also, Docker based build and setup is actually on the way. But implementing native builds would significantly enhance the training speed and provides additional opportunities for hardware-level optimization across different software/hardware setups.

cyango commented 9 months ago

Are you working on the Dockerfile? I was trying on my side, but seems my Mac is not the best machine for this

pfxuan commented 9 months ago

Not yet. I'll probably move to macos or docker build after windows-2022/-2019 build is done. Feel free to put your input at this place.

yuancaimaiyi commented 9 months ago

@pierotofy update again: machine: ubuntu20.04, cudn11.3, cudnn8.2.0, 1.10.0+cu113. This undefined reference error appears again, as follows: /usr/bin/ld: CMakeFiles/opensplat.dir/spherical_harmonics.cpp.o: in functionSphericalHarmonics::forward(torch::autograd::AutogradContext, int, at::Tensor, at::Tensor)': spherical_harmonics.cpp:(.text+0x62a): undefined reference to compute_sh_forward_tensor(unsigned int, unsigned int, unsigned int, at::Tensor&, at::Tensor&)' /usr/bin/ld: CMakeFiles/opensplat.dir/spherical_harmonics.cpp.o: in functionSphericalHarmonics::backward(torch::autograd::AutogradContext, std::vector<at::Tensor, std::allocator >)': spherical_harmonics.cpp:(.text+0xce8): undefined reference to compute_sh_backward_tensor(unsigned int, unsigned int, unsigned int, at::Tensor&, at::Tensor&)' /usr/bin/ld: CMakeFiles/opensplat.dir/cv_utils.cpp.o: in functionimreadRGB(std::string const&)': cv_utils.cpp:(.text+0x274): undefined reference to cv::imread(std::string const&, int)' /usr/bin/ld: CMakeFiles/opensplat.dir/cv_utils.cpp.o: in functionimwriteRGB(std::string const&, cv::Mat const&)': cv_utils.cpp:(.text+0x3df): undefined reference to cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)' /usr/bin/ld: CMakeFiles/opensplat.dir/cv_utils.cpp.o: in functionfloatNxNtensorToMat(at::Tensor const&)': cv_utils.cpp:(.text+0x6a3): undefined reference to cv::error(int, std::string const&, char const*, char const*, int)' /usr/bin/ld: CMakeFiles/opensplat.dir/project_gaussians.cpp.o: in functionProjectGaussians::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+0x150): undefined reference to 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)' /usr/bin/ld: CMakeFiles/opensplat.dir/project_gaussians.cpp.o: in functionProjectGaussians::backward(torch::autograd::AutogradContext, std::vector<at::Tensor, std::allocator >)': project_gaussians.cpp:(.text+0x2f4b): undefined reference to project_gaussians_backward_tensor(int, at::Tensor&, at::Tensor&, float, at::Tensor&, at::Tensor&, at::Tensor&, float, float, float, float, unsigned int, unsigned int, at::Tensor&, at::Tensor&, at::Tensor&, at::Tensor&, at::Tensor&, at::Tensor&)' /usr/bin/ld: CMakeFiles/opensplat.dir/rasterize_gaussians.cpp.o: in functionbinAndSortGaussians(int, int, at::Tensor, at::Tensor, at::Tensor, at::Tensor, std::tuple<int, int, int>)': rasterize_gaussians.cpp:(.text+0xac): undefined reference to map_gaussian_to_intersects_tensor(int, int, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, std::tuple<int, int, int>)' /usr/bin/ld: rasterize_gaussians.cpp:(.text+0x173): undefined reference toget_tile_bin_edges_tensor(int, at::Tensor const&)' /usr/bin/ld: CMakeFiles/opensplat.dir/rasterize_gaussians.cpp.o: in function RasterizeGaussians::forward(torch::autograd::AutogradContext*, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, int, int, at::Tensor)': rasterize_gaussians.cpp:(.text+0x5ba): undefined reference torasterize_forward_tensor(std::tuple<int, int, int>, std::tuple<int, int, int>, std::tuple<int, int, int>, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&)' /usr/bin/ld: CMakeFiles/opensplat.dir/rasterize_gaussians.cpp.o: in function RasterizeGaussians::backward(torch::autograd::AutogradContext*, std::vector<at::Tensor, std::allocator<at::Tensor> >)': rasterize_gaussians.cpp:(.text+0xfcf): undefined reference torasterize_backward_tensor(unsigned int, unsigned int, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&, at::Tensor const&)' collect2: error: ld returned 1 exit status`

I decided to give up . Let’s wait for the dockerfile to come out.

yuancaimaiyi commented 9 months ago

@pierotofy update I solve it ,I use libtorch-cxx11-abi-shared-with-deps-1.10.0+cu113 rather than libtorch-shared-with-deps-1.10.0+cu113 ,the "undefined reference" error disappears! image