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

Error while importing Tensorflow-text: undefined symbol #963

Closed
Tangogow opened this issue Jun 30, 2022 · 17 comments
Closed

Error while importing Tensorflow-text: undefined symbol #963

Tangogow opened this issue Jun 30, 2022 · 17 comments

Comments

@Tangogow
Copy link

Tangogow commented Jun 30, 2022

Tensorflow-text: 2.9.0
Tensorflow: 2.9.1
Python: 3.7.13

Happen only with 2.9.0
2.10.0b2 and 2.8.2rc1 seems to be working.

In Google Collab.

Similar to closed #325 two years ago.

import tensorflow_text as text
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-30-40513338c6fc>](https://localhost:8080/#) in <module>()
      1 import tensorflow_hub as hub
      2 import pandas as pd
----> 3 import tensorflow_text as text
      4 import matplotlib.pyplot as plt
      5 from sklearn.model_selection import train_test_split

[/usr/local/lib/python3.7/dist-packages/tensorflow_text/__init__.py](https://localhost:8080/#) in <module>()
     18 

     19 # pylint: disable=wildcard-import
---> 20 from tensorflow_text.core.pybinds import tflite_registrar
     21 from tensorflow_text.python import keras
     22 from tensorflow_text.python import metrics

ImportError: /usr/local/lib/python3.7/dist-packages/tensorflow_text/core/pybinds/tflite_registrar.so: undefined symbol: _ZN4absl12lts_2021110220raw_logging_internal21internal_log_functionB5cxx11E
@broken
Copy link
Member

broken commented Jul 7, 2022

Do you have an example colab? When I try this using one of the guides (and editing it to use tensorflow_text==2.9.*) I don't have the same issue.
https://colab.research.google.com/github/tensorflow/text/blob/master/docs/guide/tokenizers.ipynb#scrollTo=ISEUjIsYAl2S

What I think may be happening is that you are importing tensorflow before pip installing tensorflow_text. That loads TF libs in colab that are incompatible with tf text 2.9.x. The default TF of Colab is 2.8.2 at the moment, which would explain why TF Text 2.8.x (and 2.10 beta) work because they are built to work with TF 2.8.x, so Colab does not need to pip install a new version of TF.

If you disconnect the runtime, connect again, and pip install tensorflow_text with the first code block, do you receive the same error?

@sungengyi
Copy link

I got the same problem today when importing tensorflow_models on colab.

import tensorflow_models as tfm

It was alright yesterday.

@broken
Copy link
Member

broken commented Jul 12, 2022

Do you have an example colab?

What version of tensorflow_text are you installing? Are you importing tensorflow before pip installing tensorflow_text?

@sungengyi
Copy link

sungengyi commented Jul 12, 2022

https://colab.research.google.com/drive/1z5Z_pTMydh778t51BXY9S_AroaVz1GjY#scrollTo=J_AHTSj8SUGI

: ) Here you go.
tensorflow_text is always the first thing I pip installed, and I checked tf.version is indeed 2.9.1.

@jessechancy
Copy link

jessechancy commented Jul 12, 2022

Have the same problem too! Only stopped working today. I'm using it with keras-nlp, and it breaks keras-nlp import.

@sungengyi
Copy link

Have the same problem too! Only stopped working today

I've encountered several sudden version issues on colab with tf/keras in the past 2 month...

I was using codes from the older tutorial then after May 23rd the code broke. I rewrote it with the up-to-date version but cannot get the model to perform the same anymore...

@broken
Copy link
Member

broken commented Jul 13, 2022

My example looks like it is failing now too. There doesn't seem to be a problem outside of colab. Let me find somebody that can help out with this.

@broken
Copy link
Member

broken commented Jul 13, 2022

Trying to install 2.8.x versions results in an error from tfm too.

AttributeError                            Traceback (most recent call last)
[<ipython-input-4-3b7de3fd28ed>](https://localhost:8080/#) in <module>()
----> 1 import tensorflow_models as tfm

19 frames
[/usr/local/lib/python3.7/dist-packages/cv2/gapi/__init__.py](https://localhost:8080/#) in <module>()
    288 
    289 
--> 290 cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline

AttributeError: module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'

@broken
Copy link
Member

broken commented Jul 13, 2022

Colab is now aware of the issue and is looking into it.

@broken
Copy link
Member

broken commented Jul 13, 2022

The issue with tensorflow_text 2.9.0 on colab has been resolved. @jessechancy This fix includes its error with keras_nlp.

@sungengyi While there should no longer be a problem with tensorflow_text, they are still looking into tensorflow_models. Do you know if this worked before? The fact that it fails with TF 2.8.x and there haven't been changes there in awhile makes us think this has just flown under the radar for some time.

@sungengyi
Copy link

@broken Yes, I can confirm tfm can be imported and run before Monday Jun11th. I think it broke roughly the same time as tf text.

AttributeError: module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'

This is the new error I got. I guess colab has its environment updated on May 23rd and Jun11th. Then the versions don't match anymore and cause my first issue and this one.

@broken
Copy link
Member

broken commented Jul 20, 2022

The problem with tensorflow_models is now fixed in colab too.

@sungengyi I confirmed with your example above.

cheers!

@broken broken closed this as completed Jul 27, 2022
@broken broken mentioned this issue Aug 8, 2022
@steve-marmalade
Copy link

steve-marmalade commented Aug 15, 2022

I just encountered this issue after running pip install tensorflow-text==2.9.0 in a container image based on the m95 deeplearning release of tf-gpu.2-9, which was announced on 8/12/22.

>>> import tensorflow_text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.7/site-packages/tensorflow_text/__init__.py", line 20, in <module>
    from tensorflow_text.core.pybinds import tflite_registrar
ImportError: /opt/conda/lib/python3.7/site-packages/tensorflow_text/core/pybinds/tflite_registrar.so: undefined symbol: _ZN4absl12lts_2021110220raw_logging_internal21internal_log_functionB5cxx11E

Is the solution that was identified for colab something I can manually run?

Edit: Falling back to the tf-gpu.2-9:m95 image with tensorflow_text==2.8.2 works fine.

@broken
Copy link
Member

broken commented Aug 19, 2022

I think this may be because you are using conda. Can you try it with the system install or pyenv? See #644 for more info on this.

@andysingal
Copy link

I am having issue:
import tensorflow_models as tfm

ImportError Traceback (most recent call last)
in <cell line: 6>()
4 import numpy as np
5 import tensorflow as tf
----> 6 import tensorflow_models as tfm
7
8 import time

21 frames
/usr/local/lib/python3.10/dist-packages/keras/utils/init.py in
18
19 # Serialization related
---> 20 from keras.saving.legacy.serialization import deserialize_keras_object
21 from keras.saving.legacy.serialization import serialize_keras_object
22 from keras.saving.object_registration import CustomObjectScope

ImportError: cannot import name 'deserialize_keras_object' from partially initialized module 'keras.saving.legacy.serialization' (most likely due to a circular import) (/usr/local/lib/python3.10/dist-packages/keras/saving/legacy/serialization.py)


NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

@moisesosorio
Copy link

I got the same error, somebody found the solution?

cannot import name 'deserialize_keras_object' from partially initialized module 'keras.saving.legacy.serialization' (most likely due to a circular import) (/home/mosorio/Developments/dsProject/jupyter/venv/lib/python3.10/site-packages/keras/saving/legacy/serialization.py)

@broken
Copy link
Member

broken commented Sep 25, 2023

@moisesosorio This looks like a Keras issue. You should open an issue in with Keras and ask them.

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

7 participants