“unsupported/Eigen/CXX11/Tensor: No such file or directory” while working with TensorFlow

烂漫一生 提交于 2019-12-03 18:56:50

I (and many others) agonized over the same problem. It probably can be solved using bazel but I don't know that tool well enough and now I solve this using make. The source of confusion is that a file named Tensor is included and it itself includes a file named Tensor, which has caused some people to wrongly conclude Tensor is including itself.

If you built and installed the python .whl file there will be a tensorflow directory in dist-packages and an include directory below that, e.g. on my system:

/usr/local/lib/python2.7/dist-packages/tensorflow/include

From the include directory

find . -type f -name 'Tensor' -print
./third_party/eigen3/unsupported/Eigen/CXX11/Tensor
./external/eigen_archive/unsupported/Eigen/CXX11/Tensor

The first one has

#include "unsupported/Eigen/CXX11/Tensor"

and the file that should satisfy this is the second one.

So to compile session.cc that includes session.h, the following will work

INC_TENS1=/usr/local/lib/python2.7/dist-packages/tensorflow/include/
INC_TENS2=${INC_TENS1}external/eigen_archive/
gcc -c -std=c++11 -I $INC_TENS1 -I $INC_TENS2 session.cc

I've seen claims that you must build apps from the tensorflow tree and you must use bazel. However, I believe all the header files you need are in dist-packages/tensorflow/include and at least for starters you can construct makefile or cmake projects.

the problem was actually in the relative path of the header file taken in the Tensor file.

installed path for Tensor is /usr/include/eigen3/unsupported/Eigen/CXX11/Tensor

but mentioned in the Tensor file is "unsupported/Eigen/CXX11/Tensor"

So there should be an entry upto /usr/include/eigen3/ in the project path to run this correctly so that it can be used.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!