Cannot import `tensorflow_text` due to "undefined symbol" error
jbischof opened this issue · 5 comments
I am able to install the library on my linux machine but cannot successfully import it in python. Note that this is a CPU only machine and I am using miniconda following the instructions on https://www.tensorflow.org/install/pip?authuser=1#step-by-step_instructions.
In the shell:
conda create --name tf python=3.9
conda activate tf
pip install tensflowflow-text
python -c "import tensorflow_text"
Result:
2022-08-19 03:24:43.084113: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-08-19 03:24:43.199920: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2022-08-19 03:24:43.199961: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-08-19 03:24:44.033625: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory
2022-08-19 03:24:44.033711: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory
2022-08-19 03:24:44.033736: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.saving.functional_saver has been moved to tensorflow.python.checkpoint.functional_saver. The old module will be deleted in version 2.11.
WARNING:tensorflow:Please fix your imports. Module tensorflow.python.training.saving.checkpoint_options has been moved to tensorflow.python.checkpoint.checkpoint_options. The old module will be deleted in version 2.11.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/google/home/bischof/miniconda3/envs/tf2/lib/python3.9/site-packages/tensorflow_text/__init__.py", line 20, in <module>
from tensorflow_text.core.pybinds import tflite_registrar
ImportError: /usr/local/google/home/bischof/miniconda3/envs/tf2/lib/python3.9/site-packages/tensorflow_text/core/pybinds/tflite_registrar.so: undefined symbol: _ZN4absl12lts_2021110210CHexEscapeB5cxx11ENS0_11string_viewE
It's a known issue that tf-text is incompatible with miniconda. Please take a look at #644 for more info. I recommend using pyenv
instead for managing different python versions. I have yet to find issues with it.
Thanks for your quick response @broken, using pyenv
worked! Very sad to have my dump my conda
workflow but I hope this is fixed eventually.
Would reinstalling tensorflow along with tf-text fix things? pip install -U tensorflow_text tensorflow
or something like that.
miniconda is now the recommend installation method on the core tf docs so I wonder if there's something more we can do here.
@mattdangerw That documentation isn't installing TensorFlow using conda. It's installing Cuda using conda, then pointing the TF installed with pip to those installation directories.
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
python3 -m pip install tensorflow
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
This documentation is how to install and use TF with conda.
conda create -n tf tensorflow
conda activate tf
Review #644 on why pip installing TF in a conda environment may break TF. However, if it works for you, then feel free.
@broken thanks! Perhaps what I should be asking then is the following something that should be supported with tf-text?
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
python3 -m pip install tensorflow tensorflow-text
I definitely see how pulling tf from conda and tf-text from pip would be a bad can of worms.
But it would be nice to support roughly the same flow as the core tf install guide for both tf-text and keras-nlp on top of it.