deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.48k stars 508 forks source link

How to integrate DeePMD-kit v3 with third-party packages such as ABACUS #4140

Closed YuLiu98 closed 1 month ago

YuLiu98 commented 1 month ago

Summary

DeePMD-kit v2 can be integrated with third-party packages such as ABACUS according to the doc: https://github.com/deepmodeling/deepmd-kit/blob/master/doc/inference/cxx.md

DeePMD-kit v3 can also do it and can be used to run MD with *.pb models. However, it will report the following error:

terminate called after throwing an instance of 'deepmd::hpp::deepmd_exception'
  what():  DeePMD-kit C API Error: DeePMD-kit Error: PyTorch backend is not built

How to solve this problem?

DeePMD-kit Version

v3.0.0b3

Backend and its version

TensorFlow

Python Version, CUDA Version, GCC Version, LAMMPS Version, etc

No response

Details

Note that the libdeepmd_c.tar.gz of DeePMD-kit v3.0.0b3 is integrated with abacus in this issue. It seems to lack the torch library in the lib folder:

libdeepmd_cc.so  libdeepmd_dyn_cudart.so  libdeepmd_op.so  libtensorflow_cc.so.2
libdeepmd_c.so   libdeepmd_op_cuda.so     libdeepmd.so     libtensorflow_framework.so.2
njzjz commented 1 month ago

For the reasons listed in https://github.com/deepmodeling/deepmd-kit/issues/3120#issuecomment-1915726127, the pre-compiled package is not compiled against PyTorch. Please tell me if you have any idea.


Anyway, you can compile by yourself.

YuLiu98 commented 1 month ago

For the reasons listed in #3120 (comment), the pre-compiled package is not compiled against PyTorch. Please tell me if you have any idea.

Anyway, you can compile by yourself.

Thank you. I have compile it by off-line packages. However, it reports the error:

terminate called after throwing an instance of 'deepmd::hpp::deepmd_exception'
  what():  DeePMD-kit C API Error: DeePMD-kit Error: DeePMD-kit PyTorch backend error: Method 'has_message_passing' is not defined.
Exception raised from get_method at /home/liuyu/soft/deepmd-v3b/include/torch/csrc/jit/api/object.h:110 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0xb2 (0x7281037975d2 in /home/liuyu/soft/test_deepmd/lib/././libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0xd2 (0x72810374cc3b in /home/liuyu/soft/test_deepmd/lib/././libc10.so)
frame #2: <unknown function> + 0x2e0c2 (0x728103c2a0c2 in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #3: <unknown function> + 0x2e458 (0x728103c2a458 in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #4: deepmd::DeepPotPT::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x2d5 (0x728103c2dec5 in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #5: deepmd::DeepPotPT::translate_error(std::function<void ()>) + 0x27 (0x728103c25a77 in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #6: deepmd::DeepPotPT::DeepPotPT(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x118 (0x728103c2a3b8 in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #7: deepmd::DeepPot::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x150 (0x728103c216f0 in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #8: deepmd::DeepPot::DeepPot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x1a (0x728103c2189a in /home/liuyu/soft/test_deepmd/lib/./libdeepmd_cc.so)
frame #9: DP_NewDeepPotWithParam2 + 0xe3 (0x72810497ecc3 in /home/liuyu/soft/test_deepmd/lib/libdeepmd_c.so)
frame #10: ../../../build/abacus() [0x996f84]
frame #11: ../../../build/abacus() [0x996718]
frame #12: ../../../build/abacus() [0x7db3d6]
frame #13: ../../../build/abacus() [0x7dadaf]
frame #14: ../../../build/abacus() [0x417f53]
frame #15: <unknown function> + 0x29d90 (0x7280f7829d90 in /lib/x86_64-linux-gnu/libc.so.6)
frame #16: __libc_start_main + 0x80 (0x7280f7829e40 in /lib/x86_64-linux-gnu/libc.so.6)
frame #17: ../../../build/abacus() [0x417de5]
njzjz commented 1 month ago

Thank you. I have compile it by off-line packages. However, it reports the error:

See #3954