Skip to content
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

NotFoundError: _tfq_simulate_ops.so #180

Closed
we-taper opened this issue Mar 31, 2020 · 10 comments
Closed

NotFoundError: _tfq_simulate_ops.so #180

we-taper opened this issue Mar 31, 2020 · 10 comments

Comments

@we-taper
Copy link
Contributor

we-taper commented Mar 31, 2020

Upon fresh installation of tensorflow quantum in a conda environment, importing tensorfloq_quantum gives:

NotFoundError: XXXXXX/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/_tfq_simulate_ops.so: undefined symbol: _ZN10tensorflow12OpDefBuilder5InputESs

In more detail:

---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/load_module.py in load_module(name)
     41         path = resource_loader.get_path_to_datafile(name)
---> 42         return load_library.load_op_library(path)
     43     except:

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_core/python/framework/load_library.py in load_op_library(library_filename)
     56   """
---> 57   lib_handle = py_tf.TF_LoadLibrary(library_filename)
     58   try:

NotFoundError: /home/hx/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/_tfq_simulate_ops.so: undefined symbol: _ZN10tensorflow12OpDefBuilder5InputESs

During handling of the above exception, another exception occurred:

NotFoundError                             Traceback (most recent call last)
<ipython-input-3-def8eb400eeb> in <module>
      1 import tensorflow as tf
----> 2 import tensorflow_quantum as tfq
      3 
      4 import cirq
      5 import sympy

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/__init__.py in <module>
     16 
     17 # Import basic ops and op getters.
---> 18 from tensorflow_quantum.core import (append_circuit, get_expectation_op,
     19                                      get_sampled_expectation_op,
     20                                      get_sampling_op, get_state_op,

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/__init__.py in <module>
     15 """Imports to tensorflow_quantum.core.* level."""
     16 # Import getters for constructing ops.
---> 17 from tensorflow_quantum.core.ops import (get_expectation_op,
     18                                          get_sampled_expectation_op,
     19                                          get_sampling_op, get_state_op)

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/__init__.py in <module>
     16 
     17 # Import getters for constructing ops.
---> 18 from tensorflow_quantum.core.ops.circuit_execution_ops import (
     19     get_expectation_op, get_sampled_expectation_op, get_sampling_op,
     20     get_state_op)

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/circuit_execution_ops.py in <module>
     17 
     18 import cirq
---> 19 from tensorflow_quantum.core.ops import (cirq_ops, tfq_simulate_ops,
     20                                          tfq_utility_ops)
     21 

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/tfq_simulate_ops.py in <module>
     17 from tensorflow_quantum.core.ops.load_module import load_module
     18 
---> 19 SIM_OP_MODULE = load_module("_tfq_simulate_ops.so")
     20 
     21 

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/load_module.py in load_module(name)
     44         path = os.path.join(get_python_lib(), "tensorflow_quantum/core/ops",
     45                             name)
---> 46         return load_library.load_op_library(path)

~/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_core/python/framework/load_library.py in load_op_library(library_filename)
     55     RuntimeError: when unable to load the library or get the python wrappers.
     56   """
---> 57   lib_handle = py_tf.TF_LoadLibrary(library_filename)
     58   try:
     59     wrappers = py_tf.GetPythonWrappers(py_tf.TF_GetOpList(lib_handle))

NotFoundError: XXXXXX/miniconda3/envs/tensorflow_quantum/lib/python3.6/site-packages/tensorflow_quantum/core/ops/_tfq_simulate_ops.so: undefined symbol: _ZN10tensorflow12OpDefBuilder5InputESs

Other information:

$ python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
unknown 2.1.0

OS: Ubuntu 19.10
Package Versions:

cirq==0.7.0
pathos==0.2.5
tensorflow-quantum==0.2.0
tensorflow==2.1.0
@MichaelBroughton
Copy link
Collaborator

Hi, which directions did you follow to install tensorflow and tensorflow-quantum ? I see that your GIT_VERSION is unknown. Usually on vanilla pip installations you get a known git version of some kind. Could you give some more details on the steps you went through for your installation so I could try to recreate the issue ?

@we-taper
Copy link
Contributor Author

we-taper commented Mar 31, 2020

Thanks for the reply. The steps includes:

conda create -n tensorflow_quantum python=3.6
# ... activate the virtual environment
conda install tensorflow-gpu=2.1.0
pip install cirq==0.7.0 pathos==0.2.5 tensorflow-quantum==0.2.0
python -c "import tensorflow_quantum"

I am not sure why there would be a GIT_VERSION as I did not pull the code from git?

@MichaelBroughton
Copy link
Collaborator

MichaelBroughton commented Mar 31, 2020

I think I've managed to recreate the issue and get to the bottom of things. When I followed your instructions and then ran conda list I saw:

# Name                    Version                   Build  Channel
tensorflow                2.1.0           gpu_py36h2e5cdaa_0 
cirq                      0.7.0                    pypi_0    pypi

Notably the channel is not pypi, which leads me to believe that conda may have rolled their own version of tensorflow that might not have been compiled with the appropriate flags needed to support tensorflow quantum. These flags are present in our supported pip release of tensorflow 2.1.0. To work around this you can do this:

conda create -n tensorflow_quantum python=3.6
# ... activate the virtual environment
pip install tensorflow-gpu=2.1.0
pip install cirq==0.7.0 pathos==0.2.5 tensorflow-quantum==0.2.0
python -c "import tensorflow_quantum"

I tested this on my machine and things worked. I have virtually zero experience with conda, but I'd say the problem of getting tensorflow quantum to work with conda install would ultimately be up to the conda community to get tfq built on their platform such that it is compatible with whatever version of tensorflow they have.

Does the above fix work on your machine ?

@we-taper
Copy link
Contributor Author

we-taper commented Apr 4, 2020

Hi Micheal, sorry for getting back late. Yes using tensorflow from pip solved the issue. Thanks!

@we-taper we-taper closed this as completed Apr 4, 2020
@Raghvender1205
Copy link

I implemented all these, but still error occurs.

@timchen007
Copy link

I have one issue when import tensorflow_quantum as tfq the error message as below:
tensorflow.python.framework.errors_impl.NotFoundError: /usr/lib/python3/dist-
packages/tensorflow_quantum/core/ops/_tfq_simulate_ops.so: undefined symbol: _ZN10tensorflow8OpKernel11TraceStringEPNS_15OpKernelContextEb

My platform is pi4B and I have built tensorflow_quamtum source successful

@MichaelBroughton
Copy link
Collaborator

This looks like an issue with ABI mismatch like the one encountered in #330. If you are sure that you have all the right versions for the latest TFQ (TF 2.3.1 , TFQ 04.0 (or 0.5.0dev), cirq 0.9.1) and have built from source with the correct flags (-D_GLIBCXX_USE_CXX11_ABI=0) then it may just come down to a discrepancy between the pi4B and whatever OS it is running.

As a final note: I will say also that we don't officially test or support TFQ on pi4B so past these sorts of suggestions I don't know if I can offer too much more insight.

@timchen007
Copy link

timchen007 commented Dec 5, 2020 via email

@praddhumnasoni
Copy link

the same issue i am getting, is there any solution for the same.

@lockwo
Copy link
Contributor

lockwo commented Jul 7, 2023

Yes, see any number of the above linked issues, e.g. the one right above your comment solved this issue: #777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants