Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow Op: how to include libtensorflow_framework.so?

I followed the instructions of this tutorial: https://www.tensorflow.org/extend/adding_an_op#implement_the_gradient_in_python. There is this comment provided: g++ -std=c++11 -shared zero_out.cc -o zero_out.so -fPIC -I$TF_INC -I$TF_INC/external/nsync/public -L$TF_LIB -ltensorflow_framework -O2

But the linker cannot find -ltensorflow_framework (it should be a tensorflow_frameowork.so file!?)

After some research, I found following links:

  • https://github.com/tensorflow/tensorflow/issues/1569
  • https://github.com/eaplatanios/tensorflow_scala/issues/26 --> I downloaded the .jar and linked it via -l/pathto/tensorflow_framework.so, still the fatal error: tensorflow/core/framework/op_kernel.h: No such file or directory is not found.
  • https://github.com/tensorflow/tensorflow/issues/1270 last comment does not work and so does not help me.

I tried to search for sudo find /usr/. -name "tensorflow_framework.so" recursively but I could not find anything. Tensorflow is installed for sure via anaconda and I also cloned and compiled the repository from source.

How to find a way to include the -ltensorflow_framework?

like image 688
j35t3r Avatar asked Dec 20 '17 12:12

j35t3r


2 Answers

One answer, I have found:

I have installed my python via anaconda2 and I always tried to find out TF_INC and TF_LIB when I activated my repository source activate <env>. and the could not found any ~/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow *.so files

This time I went out every python environment with the shell command source deactivate and I typed the following command python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())'

Now, I got a different path: ~/anaconda2/lib/python2.7/site-packages/tensorflow, where the lib libtensorflow_framework.so is located.

like image 110
j35t3r Avatar answered Nov 15 '22 01:11

j35t3r


In my case, the file libtensorflow_framework.so.1 existed inside my TF_LIB directory instead of libtensorflow_framework.so. In order to solve this issue, I had to create a symbolic link as follows:

ln -s libtensorflow_framework.so.1 libtensorflow_framework.so

Source: Tensorflow NotFoundError: libtensorflow_framework.so: cannot open shared file or directory

like image 40
Moiz Sajid Avatar answered Nov 15 '22 02:11

Moiz Sajid