[Machine Learning] nglod's sdfRender Reproduction Guide (Compilation Pitfall: [CMakeFiles/sdfRenderer.dir/build.make:187: sdfRenderer] Error 1)

Official readme document

Neural SDF Renderer

This is the real-time rendering code.

Build Instructions

First, make sure you have cub installed (it comes pre-installed for newer version of CUDA).

Then, download libtorch from the PyTorch website and extract as libtorch into the third-party directory. Then:

mkdir build
cd build
cmake ../
make -j8

To run,

./sdfRenderer {path_to_model.npz}

Main pitfalls

1. libtorch version problem

  • my environment
    • free20.04
    • miracles 11.1
    • nvidia 3090, computing power 86, pytorch1.8.0 has been installed
    • gcc/g++ version 9.4.0
  • Tried libtorch versions
    • Pre-cxx11 ABI
      • libtorch 1.8.2+cu102 failed. First, the cuda version is wrong?
      • libtorch 1.8.2+cu111 failed, the libtorch version does not correspond to the pytorch version? (not necessarily)
      • libtorch 1.8.0+cu111 failed. The correspondence between libtorch version and pytorch version still does not work. Is there a problem with cxx version?
    • cxx11 ABI
      • libtorch-1.8.0+cu111 successful

1.1 Failure result record

Insert image description here

/usr/bin/ld: CMakeFiles/sdfRenderer.dir/sdfRenderer.cpp.o: in function main': sdfRenderer.cpp:(.text+0x297c): undefined reference to SPC::LoadNPZ(std::string)’
/usr/bin/ld: sdfRenderer.cpp:(.text+0x29c0): undefined reference to SDF::loadWeights(std::string)' /usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::StorageImpl::StorageImpl(c10::StorageImpl::use_byte_size_t, unsigned long, c10::DataPtr, c10::Allocator*, bool)‘:
tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN3c1011StorageImplC2ENS0_15use_byte_size_tEmNS_7DataPtrEPNS_9AllocatorEb[_ZN3c1011StorageImplC5ENS0_15use_byte_size_tEmNS_7DataPtrEPNS_9AllocatorEb]+0x158): undefined reference to c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' /usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::IndexError::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)’:
tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN3c1010IndexErrorCI2NS_5ErrorEENS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN3c1010IndexErrorCI5NS_5ErrorEENS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x30): undefined reference to c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' /usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function at::Context::getDeviceFromPtr(void*, c10::DeviceType)‘:
tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN2at7Context16getDeviceFromPtrEPvN3c1010DeviceTypeE[_ZN2at7Context16getDeviceFromPtrEPvN3c1010DeviceTypeE]+0x106): undefined reference to c10::DeviceTypeName[abi:cxx11](c10::DeviceType, bool)' /usr/bin/ld: tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN2at7Context16getDeviceFromPtrEPvN3c1010DeviceTypeE[_ZN2at7Context16getDeviceFromPtrEPvN3c1010DeviceTypeE]+0x172): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function at::from_blob(void*, c10::ArrayRef<long>, c10::ArrayRef<long>, c10::TensorOptions const&)': tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN2at9from_blobEPvN3c108ArrayRefIlEES3_RKNS1_13TensorOptionsE[_ZN2at9from_blobEPvN3c108ArrayRefIlEES3_RKNS1_13TensorOptionsE]+0x1c2): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::ValueError::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN3c1010ValueErrorCI2NS_5ErrorEENS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN3c1010ValueErrorCI5NS_5ErrorEENS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x30): undefined reference to c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::intrusive_ptr<c10::StorageImpl, c10::detail::intrusive_target_default_null_type<c10::StorageImpl> > c10::intrusive_ptr<c10::StorageImpl, c10::detail::intrusive_target_default_null_type<c10::StorageImpl> >::make<c10::StorageImpl::use_byte_size_t, unsigned long&, c10::DataPtr, c10::Allocator*&, bool&>(c10::StorageImpl::use_byte_size_t&&, unsigned long&, c10::DataPtr&&, c10::Allocator*&, bool&)': tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN3c1013intrusive_ptrINS_11StorageImplENS_6detail34intrusive_target_default_null_typeIS1_EEE4makeIJNS1_15use_byte_size_tERmNS_7DataPtrERPNS_9AllocatorERbEEES5_DpOT_[_ZN3c1013intrusive_ptrINS_11StorageImplENS_6detail34intrusive_target_default_null_typeIS1_EEE4makeIJNS1_15use_byte_size_tERmNS_7DataPtrERPNS_9AllocatorERbEEES5_DpOT_]+0x1cf): undefined reference to c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::intrusive_ptr<c10::StorageImpl, c10::detail::intrusive_target_default_null_type<c10::StorageImpl> >::retain_()': tmpxft_00218957_00000000-6_SDF.cudafe1.cpp:(.text._ZN3c1013intrusive_ptrINS_11StorageImplENS_6detail34intrusive_target_default_null_typeIS1_EEE7retain_Ev[_ZN3c1013intrusive_ptrINS_11StorageImplENS_6detail34intrusive_target_default_null_typeIS1_EEE7retain_Ev]+0xdc): undefined reference to c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >)’
/usr/bin/ld: include/spc/libspc.a(SPC.cu.o): in function at::TensorAccessor<int, 2ul, at::DefaultPtrTraits, long> at::Tensor::accessor<int, 2ul>() const &': tmpxft_0021899f_00000000-6_SPC.cudafe1.cpp:(.text._ZNKR2at6Tensor8accessorIiLm2EEENS_14TensorAccessorIT_XT0_ENS_16DefaultPtrTraitsElEEv[_ZNKR2at6Tensor8accessorIiLm2EEENS_14TensorAccessorIT_XT0_ENS_16DefaultPtrTraitsElEEv]+0xf4): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’
/usr/bin/ld: include/spc/libspc.a(spc_raytrace_cuda.cpp.o): in function spc_raytrace(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, unsigned int)': spc_raytrace_cuda.cpp:(.text+0x156a): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’
/usr/bin/ld: spc_raytrace_cuda.cpp:(.text+0x1617): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: spc_raytrace_cuda.cpp:(.text+0x16b3): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’
/usr/bin/ld: spc_raytrace_cuda.cpp:(.text+0x174c): undefined reference to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: include/spc/libspc.a(spc_raytrace_cuda.cpp.o):spc_raytrace_cuda.cpp:(.text+0x181e): more undefined references to c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)’ follow
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sdfRenderer.dir/build.make:187: sdfRenderer] Error 1
make[1]: *** [CMakeFiles/Makefile2:177: CMakeFiles/sdfRenderer.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

After the failure, I thought it was a problem that cub was not installed.

First, make sure you have cub installed (it comes pre-installed for newer version of CUDA).

But after installation, the above error will still be reported, so it should not be a problem with cub.

1.2 Successful installation

1.2.1 Steps

cd third-party
wget https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.8.0%2Bcu111.zip
unzip libtorch-cxx11-abi-shared-with-deps-1.8.0+cu111.zip
cd ../build
cmake ..
make -j8

[LibTorch & Linux] Download various versions of LibTorch

1.2.2 Successful screenshots

Insert image description here

Using sdfRender

Guess you like

Origin blog.csdn.net/weixin_43693967/article/details/126966508