在我们的代码中编写wmake选项文件以使用LibTorch的正确语法是什么?

时间:2019-05-22 18:16:43

标签: c++ makefile openfoam libtorch

我正在使用OpenFoam求解器,目前正在研究Pytorch模型,该模型可以为我做一些计算(不重要)。现在在Pytorch中训练模型之后,我正尝试通过C ++将训练后的模型集成到openfoam中。我遵循他们网站上的tutorial。这里的问题是,上述教程利用cmake提供了编译器指令,但是openfoam仅与wmake一起使用,而我无法弄清楚提供Make / options文件指令以使用openfoam编译代码的正确语法。 >

我已经使用cmake运行了该教程,并且效果很好。我还尝试使用cmake编译后查找它生成的日志文件,并尝试在wmake中显式链接目录的链接和共享对象的路径,就像它在cmake中显示的那样。但令我沮丧的是,它根本不起作用。 libtorch / lib文件夹中的库有2种类型,一种具有.so,另一种具有.a扩展名。我已经尝试将它们链接在一起,如here所述,但这是行不通的。我通过在Linux中创建符号链接来链接.a文件。

以下是我的Make / options文件。

EXE_INC = \
    -I$(TORCH_LIBERARIES)/libtorch/include \
    -I/home/hiwi/Downloads/libtorch/include/torch/csrc/api/include \
    -I/usr/local/cuda-10.0/include

EXE_LIBS = \
    -L$(cuda10_libs) \
    -lnvToolsExt \
    -lcudart \
    -lcufft \
    -lcurand \
    -lcublas \
    -L/usr/lib/x86_64-linux-gnu \
    -lcudnn \
    -L$(cuda_libs) \
    -lculibos \
    -L$(TORCH_LINKERS) \
    -lc10 \
    -lcaffe2 \
    -lcaffe2_module_test_dynamic \
    -lonnxifi \
    -ltorch \
    -lgomp-7bcb08ae \
    -lonnxifi_dummy \
    -lbenchmark \
    -lbenchmark_main \
    -lc10d \
    -lcaffe2_protos \
    -lclog \
    -lcpuinfo \
    -lcpuinfo_internals \
    -lgloo_builder \
    -lgloo \
    -lgtest \
    -lgtest_main \
    -lmkldnn \
    -lnnpack \
    -lonnxifi_loader \
    -lonnx_proto \
    -lonnx \
    -lprotobuf \
    -lprotobuf-lite \
    -lprotoc \
    -lpthreadpool \
    -lTHD \
    -ltorch_1

我总是收到以下错误: hiwi @ muhammad-arslan-ansari:〜/ Desktop / HIWI_Data / wmake_torch $ Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::typeMetaToScalarType(caffe2::TypeMeta)': test_combustion.C:(.text+0x51a): undefined reference to c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :::中basic_string,std :: allocator> const&)' Make / linux64GccDPInt32Opt / test_combustion.o:在函数torch::autograd::Variable::AutogradMeta::set_requires_grad(bool, c10::TensorImpl*)': test_combustion.C:(.text._ZN5torch8autograd8Variable12AutogradMeta17set_requires_gradEbPN3c1010TensorImplE[_ZN5torch8autograd8Variable12AutogradMeta17set_requires_gradEbPN3c1010TensorImplE]+0x101): undefined reference to c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)'中 Make / linux64GccDPInt32Opt / test_combustion.o:在函数at::legacyTensorType(c10::TensorImpl const&)': test_combustion.C:(.text._ZN2at16legacyTensorTypeERKN3c1010TensorImplE[_ZN2at16legacyTensorTypeERKN3c1010TensorImplE]+0x1ff): undefined reference to c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)'中 Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::dtype(c10::ScalarType)': test_combustion.C:(.text._ZN3c105dtypeENS_10ScalarTypeE[_ZN3c105dtypeENS_10ScalarTypeE]+0x1e9): undefined reference to c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)'中 Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::intrusive_ptr<c10::intrusive_ptr_target, c10::detail::intrusive_target_default_null_type<c10::intrusive_ptr_target> >::reclaim(c10::intrusive_ptr_target*)': test_combustion.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): undefined reference to c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)'中 Make / linux64GccDPInt32Opt / test_combustion.o:test_combustion.C :(。text._ZZN5torch3jit6script6Method12get_executorEvENKUlvE_clEv [_ZZN5torch3jit6script6Method12get_executorEvENKUlvE_clEv:{10:} :::::::::: : test_combustion。 const&)' test_combustion.C :(。text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE [_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE] + 0x6d9):未定义对{{xx} _ic {stator,d:String:d ::::::: const&)' Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' follow Make/linux64GccDPInt32Opt/test_combustion.o: In function c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)'中 Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::Symbol::fromQualString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' test_combustion.C:(.text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE[_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE]+0x1fa): undefined reference to c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)'中 Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' test_combustion.C:(.text._ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE[_ZN5torch5zerosEN3c108ArrayRefIlEERKNS0_13TensorOptionsE]+0x7f8): undefined reference to中,torch :: jit :: Value :: uniqueNameBaseabi:cxx11 const' test_combustion.C :(。text。 ZN5torch3jit6script6Method16defaultSchemaForERKS2 [ ZN5torch3jit6script6Method16defaultSchemaForERKS2 ] + 0x6a6):对c10::raw::intrusive_ptr::incref(c10::intrusive_ptr_target*)': test_combustion.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,std :: allocator> const&)' test_combustion.C :(。text。 ZN5torch3jit6script6Method16defaultSchemaForERKS2 [ ZN5torch3jit6script6Method16defaultSchemaForERKS2 ] + 0x8f9):未定义对c10::unshapedType(std::shared_ptr<c10::Type> const&)': test_combustion.C:(.text._ZN3c1012unshapedTypeERKSt10shared_ptrINS_4TypeEE[_ZN3c1012unshapedTypeERKSt10shared_ptrINS_4TypeEE]+0x436): undefined reference to torch :: OrderedDict,std :: allocator的引用::: unique_ptr>> :: operator [](std :: __ cxx11 :: basic_string,std :: allocator> const&)const': 。test_combustion.C :( text._ZNK5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10unique_ptrINS_3jit6script6MethodESt14default_deleteISA_EEEixERKS6 _ [_ _ ZNK5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10unique_ptrINS_3jit6script6MethodESt14default_deleteISA_EEEixERKS6] + 0x135):未定义参照torch::jit::script::Method::defaultSchemaFor(torch::jit::script::Method const&)': test_combustion.C:(.text._ZN5torch3jit6script6Method16defaultSchemaForERKS2_[_ZN5torch3jit6script6Method16defaultSchemaForERKS2_]+0x15b): undefined reference to炬:: JIT ::脚本::方法:: checkInputsAgainstSchema(标准::矢量>&)': 测试_燃烧。 const&)'关注 Make / linux64GccDPInt32Opt / test_combustion.o:在函数c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' test_combustion.C:(.text._ZN5torch3jit6script6Method16defaultSchemaForERKS2_[_ZN5torch3jit6script6Method16defaultSchemaForERKS2_]+0x7a5): undefined reference to中,torch :: jit :: load(std :: __ cxx11 :: basic_string,std :: allocator> const&,c10 :: optional)' test_combustion.C :(。text.startup + 0xeed):对c10 :: Error :: Error(c10 :: SourceLocation,std :: __ cxx11 :: basic_string,std :: allocator> const&)的未定义引用 collect2:错误:ld返回1退出状态 make:*** [/ home / hiwi / Desktop / HIWI_Data / wmake_torch / test_combustion]错误1

0 个答案:

没有答案