Tensorflow Op:如何包含libtensorflow_framework.so? [英] Tensorflow Op: how to include libtensorflow_framework.so?

查看:777
本文介绍了Tensorflow Op:如何包含libtensorflow_framework.so?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了本教程的指示:
https://www.tensorflow。 org / extend / adding_an_op#implement_the_gradient_in_python
提供了此注释: 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

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

但是链接器找不到 -ltensorflow_framework (应该是tensorflow_frameowork.so文件!?)

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.

我尝试搜索 sudo find / usr /。 -name tensorflow_framework.so 递归,但是我什么也找不到。 Tensorflow可以通过anaconda进行肯定安装,并且我还从源代码中克隆并编译了存储库。

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.

如何找到一种包含 -ltensorflow_framework

推荐答案

一个答案,我发现:

我已经通过anaconda2安装了python,并且在激活存储库 source activate< env> 时,我总是试图找出TF_INC和TF_LIB。并且找不到任何〜/ anaconda2 / envs / tensorflow / lib / python2.7 / site-packages / tensorflow
* .so文件

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

这一次,我使用shell命令 source deactivate 走出了每个python环境,然后键入了以下命令
python -c'将tensorflow导入为tf; print(tf.sysconfig.get_lib())'

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())'

现在,我得到了一条不同的路径:〜/ anaconda2 /lib/python2.7/site-packages/tensorflow ,即lib libtensorflow_framework.so 所在的位置。

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

这篇关于Tensorflow Op:如何包含libtensorflow_framework.so?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆