Compilation of Libtorch with wmake rather than cmake

(Muhammad Arslan Ansari) #1

Hi,
I hope that you all are having a good day.

I am trying to use Libtorch library for my OpenFoam simulations. The problem here is that, the tutorial given on the pytorch website does it via CMake. Now the problem is, OpenFoam uses its own compilation script wmake which is based on make for the compilation of its solvers.

In the tutorial linked above it says that:

CMake is not a requirement for depending on LibTorch.

Now that means I can somehow use wmake for it. Can anybody tell me the correct procedure to link all the shared objects files in in the libtorch/lib folder in my Make/options files. I tried doing it as it is explained in the wmake link which I have attached above but it doesn’t compile and it throws following problems:

Make/linux64GccDPInt32Opt/inferFoam.o: In function `torch::autograd::Variable::AutogradMeta::set_requires_grad(bool, c10::TensorImpl*)':
inferFoam.C:(.text._ZN5torch8autograd8Variable12AutogradMeta17set_requires_gradEbPN3c1010TensorImplE[_ZN5torch8autograd8Variable12AutogradMeta17set_requires_gradEbPN3c1010TensorImplE]+0x13c): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch8autograd8Variable12AutogradMeta17set_requires_gradEbPN3c1010TensorImplE[_ZN5torch8autograd8Variable12AutogradMeta17set_requires_gradEbPN3c1010TensorImplE]+0x2a3): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o: In function `at::legacyTensorType(c10::TensorImpl const&)':
inferFoam.C:(.text._ZN2at16legacyTensorTypeERKN3c1010TensorImplE[_ZN2at16legacyTensorTypeERKN3c1010TensorImplE]+0x626): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN2at16legacyTensorTypeERKN3c1010TensorImplE[_ZN2at16legacyTensorTypeERKN3c1010TensorImplE]+0x750): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o: In function `torch::OrderedDict<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::unique_ptr<torch::jit::script::Method, std::default_delete<torch::jit::script::Method> > >::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
inferFoam.C:(.text._ZNK5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10unique_ptrINS_3jit6script6MethodESt14default_deleteISA_EEEixERKS6_[_ZNK5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10unique_ptrINS_3jit6script6MethodESt14default_deleteISA_EEEixERKS6_]+0x1c2): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o:inferFoam.C:(.text._ZN3c1013intrusive_ptrINS_20intrusive_ptr_targetENS_6detail34intrusive_target_default_null_typeIS1_EEE7reclaimEPS1_[_ZN3c1013intrusive_ptrINS_20intrusive_ptr_targetENS_6detail34intrusive_target_default_null_typeIS1_EEE7reclaimEPS1_]+0x120): more undefined references to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
Make/linux64GccDPInt32Opt/inferFoam.o: In function `torch::zeros(c10::ArrayRef<long>, c10::TensorOptions const&)':
inferFoam.C:(.text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE[_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE]+0x96): undefined reference to `c10::Symbol::fromQualString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE[_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE]+0x209): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE[_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE]+0x8d8): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE[_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE]+0x9f7): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o: In function `c10::raw::intrusive_ptr::incref(c10::intrusive_ptr_target*)':
inferFoam.C:(.text._ZN3c103raw13intrusive_ptr6increfEPNS_20intrusive_ptr_targetE[_ZN3c103raw13intrusive_ptr6increfEPNS_20intrusive_ptr_targetE]+0x147): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o: In function `void std::vector<c10::IValue, std::allocator<c10::IValue> >::_M_realloc_insert<c10::IValue const&>(__gnu_cxx::__normal_iterator<c10::IValue*, std::vector<c10::IValue, std::allocator<c10::IValue> > >, c10::IValue const&)':
inferFoam.C:(.text._ZNSt6vectorIN3c106IValueESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_[_ZNSt6vectorIN3c106IValueESaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_]+0x412): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o:inferFoam.C:(.text._ZN3c1012unshapedTypeERKSt10shared_ptrINS_4TypeEE[_ZN3c1012unshapedTypeERKSt10shared_ptrINS_4TypeEE]+0x4a7): more undefined references to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
Make/linux64GccDPInt32Opt/inferFoam.o: In function `torch::jit::script::Method::defaultSchemaFor(torch::jit::script::Method const&)':
inferFoam.C:(.text._ZN5torch3jit6script6Method16defaultSchemaForERKS2_[_ZN5torch3jit6script6Method16defaultSchemaForERKS2_]+0x174): undefined reference to `torch::jit::Value::uniqueNameBase[abi:cxx11]() const'
inferFoam.C:(.text._ZN5torch3jit6script6Method16defaultSchemaForERKS2_[_ZN5torch3jit6script6Method16defaultSchemaForERKS2_]+0x4fb): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch3jit6script6Method16defaultSchemaForERKS2_[_ZN5torch3jit6script6Method16defaultSchemaForERKS2_]+0xa77): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch3jit6script6Method16defaultSchemaForERKS2_[_ZN5torch3jit6script6Method16defaultSchemaForERKS2_]+0xdb5): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o: In function `torch::jit::script::Method::checkInputsAgainstSchema(std::vector<c10::IValue, std::allocator<c10::IValue> >&)':
inferFoam.C:(.text._ZN5torch3jit6script6Method24checkInputsAgainstSchemaERSt6vectorIN3c106IValueESaIS5_EE[_ZN5torch3jit6script6Method24checkInputsAgainstSchemaERSt6vectorIN3c106IValueESaIS5_EE]+0x407): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text._ZN5torch3jit6script6Method24checkInputsAgainstSchemaERSt6vectorIN3c106IValueESaIS5_EE[_ZN5torch3jit6script6Method24checkInputsAgainstSchemaERSt6vectorIN3c106IValueESaIS5_EE]+0x909): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o:inferFoam.C:(.text._ZN5torch3jit6script6Method24checkInputsAgainstSchemaERSt6vectorIN3c106IValueESaIS5_EE[_ZN5torch3jit6script6Method24checkInputsAgainstSchemaERSt6vectorIN3c106IValueESaIS5_EE]+0xb47): more undefined references to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
Make/linux64GccDPInt32Opt/inferFoam.o: In function `main':
inferFoam.C:(.text.startup+0x114a): undefined reference to `torch::jit::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, c10::optional<c10::Device>)'
inferFoam.C:(.text.startup+0x1a3d): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text.startup+0x4ee6): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text.startup+0x5106): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text.startup+0x530b): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
inferFoam.C:(.text.startup+0x5bbb): undefined reference to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Make/linux64GccDPInt32Opt/inferFoam.o:inferFoam.C:(.text.startup+0x5cad): more undefined references to `c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow
collect2: error: ld returned 1 exit status