-
Notifications
You must be signed in to change notification settings - Fork 74.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal messages mixing C libtensorflow with python tensorflow #7541
Comments
Yeah, I think this happens because we import pywrap_tensorflow with RTLD_GLOBAL. Unfortunately I don't think there's an easy way to make this work at the moment. It's possible we can go the other way and make the C API accessible from Keeping this open, but it's uncommon and difficult, so we may not work on it anytime soon. A possible workaround is to mangle the symbols (namespace?) in the TensorFlow shared library. |
@jhseu it would be great if the C API were available through |
I have gotten @jhseu's solution to work in #10469. Before #10469:
After #10469:
|
I'm trying to mix C++ tensorflow code with python tensorflow code instead, with tensorflow 1.4.0. Same fatal messages encountered. Is it suggested that I should link _pywrap_tensorflow_internal.so instead of libtensorflow_cc.so when compiling the C++ DDL to avoid the conflict temporarily? Unfortunately I failed. It seem that some of C++ APIs I used are not included in C APIs and have not been exported to _pywrap_tensorflow_internal.so. |
It has been 14 days with no activity and the |
I think something may have broken in the C symbol export from TF 1.3 -> 1.4, e.g. nimble-dev/nimble#638 |
It has been 14 days with no activity and the |
@allenlavoie fixed the issue @jhseu mentioned. Allen, can we close the original issue now? |
If you want to use the C API along with Python, you need in TF >=1.4 to link against _pywrap_tensorflow_internal.so (which includes the C API) and libtensorflow_framework.so (for protobuf symbols; also includes many C++ symbols). You can also build with The Python and C language bindings both include ops and kernels, so you (still) can't use both of those together, even though they both link against libtensorflow_framework.so. Potentially you could remove a bunch of duplicate registration errors to make it work, or build a version of the libtensorflow.so without ops or kernels (making that easy to build manually would be neat). I think these are issues tracked elsewhere. |
hello, peter @pwaller ; Did you solve this error of mixing python and c++ code? thanks in advance. |
@kerolos I didn't get this working in this way in the end, but I would still be interested in seeing it be possible. |
Any updates this double singleton initialisation issue? I am trying to call some Python code (that imports and runs Tensorflow) from within a C program that is linked against Tensorflow. |
I'm trying to write mixed C tensorflow code with python tensorflow code by
embedding the CPython interpreter in my application.
I'm mainly doing this because defining the model is only really possible in
Python at the moment due to the lack of gradients (#6268), and I want to define
new models from the C side at speed without needing to invoke or
communicate to an external python process to get a new model.
To reproduce the problem is quite straightforward, simply
import tensorflow
in python after the libtensorflow library has already been dynamically linked.
Here is a quick reproducer in pure python which will not run:
libtensorflow can be obtained like so:
Here are two fatal messages I have encountered (the first from the Python reproducer above, the second from a C program):
I assume the problem is that the
_pywrap_tensorflow.so
has tensorflowstatically linked into them, so they don't use libtensorflow. Then you have
two shared libraries conflicting with one another.
Is there a way to avoid this conflict?
The text was updated successfully, but these errors were encountered: