'tf.load_op_library doesn't load .so file and throws file not found error although the file exists

I have modified the code from https://github.com/ppriyank/Bert-Coref-Resolution-Lee-/tree/master/tensorflow for Coreference resolution using TensorFlow. When the code from coref_ops.py file below is executed.

print("./coref_kernels.so".is_file())
coref_op_library = tf.load_op_library(str("./coref_kernels.so"))

The first line prints True which means that the file exists. But the second line throws the following error.

File "/home/ubuntu/venvpipe1v1/lib/python3.7/site-packages/tensorflow/python/framework/load_library.py", line 54, in load_op_library lib_handle = py_tf.TF_LoadLibrary(library_filename) 
tensorflow.python.framework.errors_impl.NotFoundError: libtensorflow_framework.so.1: cannot open shared object file: No such file or directory

System Information


**System information**
== check python ===================================================
python version: 3.7.7
python branch: 
python build version: ('default', 'Jan 13 2021 07:47:31')
python compiler version: GCC 7.5.0
python implementation: CPython


== check os platform ===============================================
os: Linux
os kernel version: 69-18.04.1-Ubuntu SMP Wed Feb 9 15:36:54 UTC 2022
os release version: 5.4.0-1066-aws
os platform: Linux-5.4.0-1066-aws-x86_64-with-debian-buster-sid
linux distribution: ('debian', 'buster/sid', '')
architecture: ('64bit', '')
machine: x86_64

== compiler =====================================================
c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

== check pips ===================================================
numpy                            1.21.5
protobuf                         3.14.0
tensorflow                       2.8.0
tensorflow-estimator             1.14.0
tensorflow-hub                   0.11.0
tensorflow-io-gcs-filesystem     0.24.0
wsproto                          1.0.0

I found instances of libtensorflow_framework.so and libtensorflow_framework.so.2 using locate gives the following locations of the files

/home/ubuntu/venvpipe1v1/lib/python3.7/site-packages/tensorflow/libtensorflow_framework.so.2

Tried linking libtensorflow_framework.so and libtensorflow_framework.so.2 using ln as suggested by Tensorflow NotFoundError: libtensorflow_framework.so: cannot open shared file or directory

I have tried appending LD_LIBRARY_PATH with the libtensorflow_framework.so file as suggested by this thread https://github.com/tensorflow/tensorflow/issues/30488

I have tried downgrading to tensorflow 1.14, with Python 3.7. As that was the latest compatible according to https://www.tensorflow.org/install/source#gpu



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source