text: import fails: "undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs"

I encountered this bug which is most probably a duplicate of #30 that has been closed. Is it related to https://github.com/tensorflow/text/issues/160#issuecomment-556558082 ?

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04 LTS
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: no
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.0.0
  • Python version: Anaconda python 3.7.5
  • CUDA/cuDNN version: None
  • GPU model and memory: None

Describe the current behavior Error on importing tensorflow-text making it impossible to be imported.

Describe the expected behavior Library can be effortlessly imported and used.

Code to reproduce the issue Provide a reproducible test case that is the bare minimum necessary to generate the problem.

I created a new minimal environment using

conda create -n tf-test tensorflow python=3.7
conda activate tf-test
pip install tensorflow-text

then, when trying to import tensorflow_text the following error appears

$ python
Python 3.7.5 (default, Oct 25 2019, 15:51:11) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> import tensorflow_text as text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mathieu/miniconda3/envs/tf-test/lib/python3.7/site-packages/tensorflow_text/__init__.py", line 21, in <module>
    from tensorflow_text.python import metrics
  File "/home/mathieu/miniconda3/envs/tf-test/lib/python3.7/site-packages/tensorflow_text/python/metrics/__init__.py", line 20, in <module>
    from tensorflow_text.python.metrics.text_similarity_metric_ops import *
  File "/home/mathieu/miniconda3/envs/tf-test/lib/python3.7/site-packages/tensorflow_text/python/metrics/text_similarity_metric_ops.py", line 28, in <module>
    gen_text_similarity_metric_ops = load_library.load_op_library(resource_loader.get_path_to_datafile('_text_similarity_metric_ops.so'))
  File "/home/mathieu/miniconda3/envs/tf-test/lib/python3.7/site-packages/tensorflow_core/python/framework/load_library.py", line 61, in load_op_library
    lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/mathieu/miniconda3/envs/tf-test/lib/python3.7/site-packages/tensorflow_text/python/metrics/_text_similarity_metric_ops.so: undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 19 (3 by maintainers)

Most upvoted comments

This is a month old and doesn’t appear like a tf text issue, so I’m closing.

This doesn’t look like a legit reason to close a ticket.

This is a month old and doesn’t appear like a tf text issue, so I’m closing.

Nobody monitors closed issues, so I doubt anybody on the team has noticed any of these replies. If anybody on this thread is having a problem, please create a new issue with the error, tf version, tf text version, os, and if you are using an environment like conda or pyenv.

Same issue here using conda installed tensorflow 2.0.0 and tensorflow-text==2.0.0

This looks like a conda issue. If you don’t create the conda environment with tensorflow in the beginning it works fine.

conda create -n tf-test python=3.7
conda activate tf-test
pip install tensorflow
pip install tensorflow-text

Do you know what is different about installing it at creation vs using pip after?

Solved: I was performing tensorflow object detection training and encountered this type of error. It got resolved when I installed tensorflow version 2.1.0, above versions still has that error

I saw the same error on Colab. The solution was that the tensorflow-text version needs to match the tf version. Since Colab was using tensorflow==2.2.0, I was successfully able to install and import tensorflow-text after: !pip install tensorflow-text==2.2.0

Sorry I could not reply earlier then lost sight of your answer. This works :

pip install tensorflow
pip install tensorflow-text

but this does not :

conda install tensorflow
pip install tensorflow-text

Could it be an issue with the conda recipe for tensorflow ?

this worked for me !pip install -U tensorflow !pip install -U tensorflow-text as mentioned here https://stackoverflow.com/a/72964778/5238639

I got this error on Google Colab.

After hours of struggle, I am 99% this is some sort of a VM memory or path issue. It looks like you are using a library of one version (if you run pip list), but it’s actually a different version.

To fix this, completely disconnect and delete the runtime. If you don’t do this, I think some stuff in the memory persists forever, even if you close Colab. Then, when you switch to GPU, you will get a GPU environment with tensorflow version 2.9 installed and no tensorflow-text installed. Separately run pip install with versions specified:

pip install tensorflow==2.10 pip install tensorflow-text==2.10

This works.

If you try to run tensorflow v 2.10 with tensorflow-text v 2.9, you get this error too. This is why I believe it’s some sort of pip installation memory issue?

Makes sense that tensorflow don’t want to solve this, as it is likely just the Google Colab VM problem.

I saw the same error on Colab. The solution was that the tensorflow-text version needs to match the tf version. Since Colab was using tensorflow==2.2.0, I was successfully able to install and import tensorflow-text after: !pip install tensorflow-text==2.2.0

Thank you! I worked for me.

I have this same problem. tensorflow gets imported without problems, importing tensorflow-text results in op’s error message.

tensorflow is built from sources (1.15.3), tensorflow-text is stock binary (1.15.1, tried also 1.15.0rc0). Platform is Ubuntu 18.04.3 LTS. Python 3.6.9. Using (Mini)conda environment.

tensorflow is built without GPU support and tensorflow-gpu is not installed.

Could there still be a compatibility issue? Interestingly, people seem to have exact same issue with TF 2 as well, but here I am using version 1.15.

Any help or ideas would be greatly appreciated.

@zzj0402 install tensorflow 2.0 in kaggle notebook,then this problem will be removed

I solved it by toggle GPU on in Kaggle environment settings.

If that can help, I work in TensorFlow Java and and just tried to load directly the _wordpiece_tokenizer.so library extracted from TF-Text 2.2.0 python wheels and link it with libtensorflow_framework.so.2 that we distribute (which is built now from TF 2.2.0). I got the same error as @soumayan , who had to downgrade to TF2.0.0 if I understand correctly:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/karl/_wordpiece_tokenizer.so: undefined symbol: _ZN10tensorflow8OpKernel11TraceStringEPNS_15OpKernelContextEb

So it looks like there might be an incompatibility between TF 2.2.0 and TF-Text 2.2.0