You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to use libtorch (the C++ pytorch front-end) in a pybind extension, but I cannot get it to consistently work accross platforms. Any help or ideas are appreciated.
The bindings are just bind a function that represents a simple call to some libtorch function (for now).
On windows, I can successfully import the bindings as long as I use the "envDP" python version , i.e. the one I linked my libtorch extension from, and as long as I call:
import torch
import DP_bindings
(If I don't first import torch, I get "DLL load failed while importing DP_Bindings: The specified module could not be found." )
On Linux, however, the same calls yield errors with undefined symbols:
These errors can be avoided by ensuring that the cmake defines only a single target (DP_bindings). However, when adding a second target (say an OBJECT or a static or dynamic library), the errors consistently appear. I suspect issues with ABI compatibility. But it could be something else.
Related: #2113
(I studied their setup. In my case, I could succesfully use multiple targets, but not if I also use external libraries like libtorch.)
I am happy to try a downsized example with code, if somebody with deep pybind knowledge is interested to investigate. I would also be happy with any suggestion on other things to try.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am attempting to use libtorch (the C++ pytorch front-end) in a pybind extension, but I cannot get it to consistently work accross platforms. Any help or ideas are appreciated.
My code (cmake) add a module like so
pybind11_add_module(DP_bindings)
and find and links libtorch from anaconda:
"C:/Users//Anaconda3/envs/envDP/Lib/site-packages/torch/share/cmake"
The bindings are just bind a function that represents a simple call to some libtorch function (for now).
On windows, I can successfully import the bindings as long as I use the "envDP" python version , i.e. the one I linked my libtorch extension from, and as long as I call:
import torch
import DP_bindings
(If I don't first import torch, I get "DLL load failed while importing DP_Bindings: The specified module could not be found." )
On Linux, however, the same calls yield errors with undefined symbols:
/gpfs/home1/..../DP_Bindings.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZN8DynaPlex6ParamsC1ESt16initializer_listISt5tupleIJSsSt7variantIJbDnldSsS0_St6vectorIlSaIlEES4_IdSaIdEES4_ISsSaISsEES4_IS0_SaIS0_EEEEEEE
These errors can be avoided by ensuring that the cmake defines only a single target (DP_bindings). However, when adding a second target (say an OBJECT or a static or dynamic library), the errors consistently appear. I suspect issues with ABI compatibility. But it could be something else.
Related:
#2113
(I studied their setup. In my case, I could succesfully use multiple targets, but not if I also use external libraries like libtorch.)
Also, maybe this is related: #3793
I am happy to try a downsized example with code, if somebody with deep pybind knowledge is interested to investigate. I would also be happy with any suggestion on other things to try.
Beta Was this translation helpful? Give feedback.
All reactions