Friday, January 12, 2018

tensorflow c++ compiling problems

Problem 1

fatal error: third_party/eigen3/unsupported/Eigen/CXX11/Tensor: No such file or directory

if you pip install using virtual environment, the include files are not copied.

Solution

1. Dirty one. Install tensorflow globally.
2. The including files will be copied to
 /usr/local/lib/python2.7/dist-packages/tensorflow/
Thus, we only need to copy them to ~/tensorflow/include python2.7.
The source files are stored in
tensorflow-1.5.0-rc0/third_party/eigen3/unsupported/Eigen/CXX11


Problem 2

fatal error: nsync_cv.h: No such file or directory
fatal error: nsync_mu.h: No such file or directory

Solution

1. modify source c++ file
find /usr/local/lib/python2.7/dist-packages/tensorflow/ -name "nsync_mu.h"
/usr/local/lib/python2.7/dist-packages/tensorflow/include/external/nsync/public/nsync_mu.h

modify line 25 and 26 to include right path in /usr/local/lib/python2.7/dist-packages/tensorflow/include/tensorflow/core/platform/default/mutex.h

2. 
or modify makefile to add include path
add nsync_cv.h include:-I$TF_INC/external/nsync/public
below is official demo
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())')
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

Problem 3

Using tensorboard
  File "/home/jinglu/tensorflow/bin/tensorboard", line 7, in <module>
    from tensorboard.main import run_main

Solution

pip install tb-nightly

Problem 4


Undefined symbol: _ZTIN10tensorflow8OpKernelE

Solution

add the flags in g++
-L $TF_LIB -ltensorflow_framework 

1 comment:

  1. Hey, I'm facing the problem 2, but when I check in "dist-packages/tensorflow/include/external/" from my python install I can't find nsync under external! I've installed Tensorflow 1.4 (required by a project) from pip with python 3.6.7. Do you have any clue ?

    ReplyDelete