【机器学习】nglod的sdfRender复现指南(编译避坑 :[CMakeFiles/sdfRenderer.dir/build.make:187: sdfRenderer] Error 1)

官方的readme文档

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}

主要坑点

1.libtorch版本问题

  • 我的环境
    • ubuntu20.04
    • cuda11.1
    • nvidia 3090,算力86,已经安装pytorch1.8.0
    • gcc/g++版本 9.4.0
  • 尝试过的libtorch版本
    • Pre-cxx11 ABI
      • libtorch 1.8.2+cu102 失败,首先cuda版本错了?
      • libtorch 1.8.2+cu111 失败,libtorch版本没有和pytorch版本对应?(未必)
      • libtorch 1.8.0+cu111 失败,libtorch版本和pytorch版本对应依然不行,cxx版本问题?
    • cxx11 ABI
      • libtorch-1.8.0+cu111 成功

1.1 失败结果记录

【机器学习】nglod的sdfRender复现指南(编译避坑 :[CMakeFiles/sdfRenderer.dir/build.make:187: sdfRenderer] Error 1)_第1张图片

/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, std::allocator >)' /usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::IndexError::Error(c10::SourceLocation, std::__cxx11::basic_string)’:
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, std::allocator >)' /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 const&)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function at::from_blob(void*, c10::ArrayRef, c10::ArrayRef, 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 const&)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::ValueError::Error(c10::SourceLocation, std::__cxx11::basic_string, std::allocator >)': 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)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::intrusive_ptr > c10::intrusive_ptr >::make(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)’
/usr/bin/ld: liblib_sdf.a(SDF.cu.o): in function c10::intrusive_ptr >::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)’
/usr/bin/ld: include/spc/libspc.a(SPC.cu.o): in function at::TensorAccessor at::Tensor::accessor() 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 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 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, std::allocator > 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 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, std::allocator > 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 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

失败之后,我以为是cub没安装的问题

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

但安装过后仍然还是会报上面的错,所以应该不是cub的问题

1.2 成功安装

1.2.1 步骤

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] 各版本 LibTorch 下载

1.2.2 成功的截图

【机器学习】nglod的sdfRender复现指南(编译避坑 :[CMakeFiles/sdfRenderer.dir/build.make:187: sdfRenderer] Error 1)_第2张图片

使用sdfRender

你可能感兴趣的:(机器学习,ubuntu,3维视觉,机器学习,人工智能)