'Pathing error in Tensorflow - cannot open a .so shared object file: No such file or directory
I've been struggling with this problem for a few days and I have seen A LOT of open issues on different models from github. I am trying to run the PCN model. I installed the specified versions, in ubuntu 18.04 and in a conda environment from the same system. From what I checked, I instsalled the proper versions, changed the necessary paths in the makefile, and the necessary symbolic links for the so files etc. Make works. But when running demo.py, this error pops up.
WARNING:tensorflow:From /home/mk/.local/lib/python3.6/site-packages/tensorflow/python/compat/v2_compat.py:101: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Traceback (most recent call last):
File "demo.py", line 110, in <module>
nn_distance_module=tf.load_op_library(os.path.join(BASE_DIR, 'tf_nndistance_so.so'))
File "/home/mk/.local/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 58, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: /home/mk/Downloads/pcn-master/tf_nndistance_so.so: cannot open shared object file: No such file or directory
Makefile:
cuda_inc = /home/mk/anaconda3/envs/pcn/include/
cuda_lib = /home/mk/anaconda3/envs/pcn/lib/
nvcc = /home/mk/anaconda3/envs/pcn/bin/nvcc
tf_inc = /home/mk/anaconda3/envs/pcn/lib/python3.6/site-packages/tensorflow/include
tf_lib = /home/mk/anaconda3/envs/pcn/lib/python3.6/site-packages/tensorflow
# tf_inc=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
# tf_lib=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')
all: tf_nndistance_so.so tf_approxmatch_so.so
tf_nndistance.cu.o: tf_nndistance.cu
$(nvcc) tf_nndistance.cu -o tf_nndistance.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
tf_nndistance_so.so: tf_nndistance.cpp tf_nndistance.cu.o
g++ tf_nndistance.cpp tf_nndistance.cu.o -o tf_nndistance_so.so -shared -std=c++11 -fPIC -O2 \
-I $(tf_inc) -D_GLIBCXX_USE_CXX11_ABI=1 -L $(tf_lib) -ltensorflow_framework -L $(cuda_lib) -lcudart
tf_approxmatch.cu.o: tf_approxmatch.cu
$(nvcc) tf_approxmatch.cu -o tf_approxmatch.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
tf_approxmatch_so.so: tf_approxmatch.cpp tf_approxmatch.cu.o
g++ -shared $(CPPFLAGS) tf_approxmatch.cpp tf_approxmatch.cu.o -o tf_approxmatch_so.so -shared -std=c++11 -fPIC -O2 \
-I $(tf_inc) -D_GLIBCXX_USE_CXX11_ABI=1 -L $(tf_lib) -ltensorflow_framework -L $(cuda_lib) -lcudart
clean:
rm -rf *.o *.so
I saw that the file error was because, for some reason, the PATH is getting messed up. I copied that file (which was inside the folder where the Makefile was, a folder inside pcn-master) and pasted it in pcn-master (which is a crappy solution but just to test), and now I am getting an error regarding what I think is the symbolic linkage.
File "demo.py", line 110, in <module>
nn_distance_module=tf.load_op_library(os.path.join(BASE_DIR, 'tf_nndistance_so.so'))
File "/home/mk/.local/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 58, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: libtensorflow_framework.so: cannot open shared object file: No such file or directory
I have tried different solutions like this, and this, and a big etc. In here, although a different file error, it says to delete it...
It seems there should be a .sofile (well, actuall there are 2, a .so.2and a .soin which I need to make a symbolic link, which again I did.
~/.local/lib/python3.6/site-packages/tensorflow$ dir
_api __init__.py lite xla_aot_runtime_src
compiler keras __pycache__
core libtensorflow_framework.so python
include libtensorflow_framework.so.2 tools
locate libtensorflow_framework.so
/home/mk/.local/lib/python3.6/site-packages/tensorflow/libtensorflow_framework.so
/home/mk/.local/lib/python3.6/site-packages/tensorflow/libtensorflow_framework.so.2
mk@mk:~/.local/lib/python3.6/site-packages/tensorflow/python/framework$ nautilus .
mk@mk:~/.local/lib/python3.6/site-packages/tensorflow/python/framework$ sudo ln -s libtensorflow_framework.so.2 libtensorflow_framework.so
ln: failed to create symbolic link 'libtensorflow_framework.so': File exists
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
