libtorch link error when I try to execute make in Chamsim

37 Views Asked by At

I want Use Libtorch in Champsim Simulator,but when I execute “make”,I got:

/usr/bin/ld: obj/pref_pprefetcherDtx.a(tx.o): in function `c10::intrusive_ptr<c10::TensorImpl, c10::UndefinedTensorImpl>::retain_() [clone .isra.0]':
tx.cc:(.text._ZN3c1013intrusive_ptrINS_10TensorImplENS_19UndefinedTensorImplEE7retain_Ev.isra.0[_ZN17TemporalBlockImplC5Eiiiiiif]+0x3): undefined reference to `c10::UndefinedTensorImpl::_singleton'
/usr/bin/ld: tx.cc:(.text._ZN3c1013intrusive_ptrINS_10TensorImplENS_19UndefinedTensorImplEE7retain_Ev.isra.0[_ZN17TemporalBlockImplC5Eiiiiiif]+0x46): undefined reference to `c10::detail::torchInternalAssertFail(char const*, char const*, unsigned int, char const*, char const*)'
/usr/bin/ld: obj/pref_pprefetcherDtx.a(tx.o): in function `torch::OrderedDict<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, at::Tensor>::~OrderedDict()':
tx.cc:(.text._ZN5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN2at6TensorEED2Ev[_ZN5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN2at6TensorEED5Ev]+0x33): undefined reference to `c10::UndefinedTensorImpl::_singleton'
/usr/bin/ld: obj/pref_pprefetcherDtx.a(tx.o): in function `torch::nn::Module::~Module()':
tx.cc:(.text._ZN5torch2nn6ModuleD2Ev[_ZN5torch2nn6ModuleD5Ev]+0x9): undefined reference to `vtable for torch::nn::Module'
/usr/bin/ld: obj/pref_pprefetcherDtx.a(tx.o): in function `torch::nn::Module::_forward_populate_default_args(std::vector<torch::nn::AnyValue, std::allocator<torch::nn::AnyValue> >&&)':
tx.cc:(.text._ZN5torch2nn6Module30_forward_populate_default_argsEOSt6vectorINS0_8AnyValueESaIS3_EE[_ZN5torch2nn6Module30_forward_populate_default_argsEOSt6vectorINS0_8AnyValueESaIS3_EE]+0x71): 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: obj/pref_pprefetcherDtx.a(tx.o): in function `torch::nn::Module::_forward_num_required_args()':
tx.cc:(.text._ZN5torch2nn6Module26_forward_num_required_argsEv[_ZN5torch2nn6Module26_forward_num_required_argsEv]+0x71): 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: obj/pref_pprefetcherDtx.a(tx.o): in function `c10::intrusive_ptr<c10::TensorImpl, c10::UndefinedTensorImpl>::reset_()':
tx.cc:(.text._ZN3c1013intrusive_ptrINS_10TensorImplENS_19UndefinedTensorImplEE6reset_Ev[_ZN3c1013intrusive_ptrINS_10TensorImplENS_19UndefinedTensorImplEE6reset_Ev]+0x8): undefined reference to `c10::UndefinedTensorImpl::_singleton'
/usr/bin/ld: obj/pref_pprefetcherDtx.a(tx.o): in function `torch::nn::detail::_DropoutNd<torch::nn::DropoutImpl>::reset()':
tx.cc:(.text._ZN5torch2nn6detail10_DropoutNdINS0_11DropoutImplEE5resetEv[_ZN5torch2nn6detail10_DropoutNdINS0_11DropoutImplEE5resetEv]+0x14d): 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: obj/pref_pprefetcherDtx.a(tx.o): in function `std::shared_ptr<torch::nn::Module>& torch::OrderedDict<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::shared_ptr<torch::nn::Module> >::insert<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::shared_ptr<Chomp1dImpl> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&, std::shared_ptr<Chomp1dImpl>&&)':
tx.cc:(.text._ZN5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrINS_2nn6ModuleEEE6insertIS6_S7_I11Chomp1dImplEEERSA_OT_OT0_[_ZN5torch11OrderedDictINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrINS_2nn6ModuleEEE6insertIS6_S7_I11Chomp1dImplEEERSA_OT_OT0_]+0x1a2): 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: obj/pref_pprefetcherDtx.a(tx.o): in function `std::shared_ptr<Chomp1dImpl> torch::nn::Module::register_module<Chomp1dImpl>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::shared_ptr<Chomp1dImpl>)':
tx.cc:(.text._ZN5torch2nn6Module15register_moduleI11Chomp1dImplEESt10shared_ptrIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_[_ZN5torch2nn6Module15register_moduleI11Chomp1dImplEESt10shared_ptrIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_]+0x77): undefined reference to `typeinfo for torch::nn::Module'
/usr/bin/ld: tx.cc:(.text._ZN5torch2nn6Module15register_moduleI11Chomp1dImplEESt10shared_ptrIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_[_ZN5torch2nn6Module15register_moduleI11Chomp1dImplEESt10shared_ptrIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_]+0x10b): undefined reference to `c10::detail::torchCheckFail(char const*, char const*, unsigned int, char const*)'
/usr/bin/ld: tx.cc:(.text._ZN5torch2nn6Module15register_moduleI11Chomp1dImplEESt10shared_ptrIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_[_ZN5torch2nn6Module15register_moduleI11Chomp1dImplEESt10shared_ptrIT_ENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_]+0x156): 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&)'


I try Using Libtorch in Champsim, I change the makefile as follows:

CXXFLAGS := -I/home/tx/software/libtorch/include/torch/csrc/api/include -L/home/tx/software/libtorch/lib/ 
CXXFLAGS += -I/home/tx/software/libtorch/include/ 
CXXFLAGS += -lbackend_with_compiler
CXXFLAGS += -lc10
CXXFLAGS += -lc10_cuda
CXXFLAGS += -lc10d_cuda_test
CXXFLAGS += -lcaffe2_nvrtc
CXXFLAGS += -ljitbackend_test
CXXFLAGS += -lnnapi_backend
CXXFLAGS += -lshm
CXXFLAGS += -ltorch
CXXFLAGS += -ltorch_cpu
CXXFLAGS += -ltorch_cuda
CXXFLAGS += -ltorch_cuda_cpp
CXXFLAGS += -ltorch_cuda_cu
CXXFLAGS += -ltorch_global_deps
CXXFLAGS += -ltorchbind_test
CXXFLAGS += -Wall -O3 -std=c++17
CPPFLAGS :=  -Iinc -MMD -MP
LDFLAGS += -lbackend_with_compiler
LDFLAGS += -lc10
LDFLAGS += -lc10_cuda
LDFLAGS += -lc10d_cuda_test
LDFLAGS += -lcaffe2_nvrtc
LDFLAGS += -ljitbackend_test
LDFLAGS += -lnnapi_backend
LDFLAGS += -lshm
LDFLAGS += -ltorch
LDFLAGS += -ltorch_cpu
LDFLAGS += -ltorch_cuda
LDFLAGS += -ltorch_cuda_cpp
LDFLAGS += -ltorch_cuda_cu
LDFLAGS += -ltorch_global_deps
LDFLAGS += -ltorchbind_test
LDLIBS := -L/home/tx/software/libtorch/lib/ 

I set the right libtorch path,which is from pytorch.org,I also tried compile from source code of pytorch, but I got the same error Does anyone can help me?

0

There are 0 best solutions below