tradr-project / tensorflow_ros

Project moved to tensorflow_ros_cpp
https://github.com/tradr-project/tensorflow_ros_cpp
26 stars 10 forks source link

Error linking compiled tensorflow-gpu 1.7 #5

Open moorage opened 6 years ago

moorage commented 6 years ago

I'm on Ubuntu 16.04, and needed to compile tensorflow-gpu because of the newer nvidia drivers and cuda toolkit on this machine.

On other machines with a normal pip tensorflow install, the linking works perfectly. However, on this machine, I get:

Errors     << tensorflow_ros_node:make /home/robot/robot_ros/catkin_ws/logs/tensorflow_ros_node/build.make.000.log                                                                                      
libtf_ros_node_lib.so: undefined reference to `tensorflow::TensorShapeRep::DebugString() const'
libtf_ros_node_lib.so: undefined reference to `tensorflow::strings::StrCat(tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&)'
libtf_ros_node_lib.so: undefined reference to `tensorflow::internal::CheckOpMessageBuilder::NewString()'
libtf_ros_node_lib.so: undefined reference to `tensorflow::ReadBinaryProto(tensorflow::Env*, std::string const&, google::protobuf::MessageLite*)'
libtf_ros_node_lib.so: undefined reference to `tensorflow::Status::empty_string()'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/robot/robot_ros/catkin_ws/devel/.private/tensorflow_ros_node/lib/tensorflow_ros_node/tensorflow_ros_node] Error 1
make[1]: *** [CMakeFiles/tensorflow_ros_node.dir/all] Error 2
make: *** [all] Error 2
cd /home/robot/robot_ros/catkin_ws/build/tensorflow_ros_node; catkin build --get-env **tensorflow_ros_node** | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -

Note: on both the working machine and this non-working machine, we also get:

Found pip-installed tensorflow: /usr/local/lib/python2.7/dist-packages/tensorflow
Using Tensorflow library /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Created tensorflow library link /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so -> /home/robot/robot_ros/catkin_ws/devel/.private/tensorflow_ros/lib/_pywrap_tensorflow_internal.so.
Created tensorflow library link /usr/local/lib/python2.7/dist-packages/tensorflow/libtensorflow_framework.so -> /home/robot/robot_ros/catkin_ws/devel/.private/tensorflow_ros/lib/libtensorflow_framework.so.
cd /home/robot/robot_ros/catkin_ws/build/tensorflow_ros; catkin build --get-env tensorflow_ros | catkin env -si  /usr/bin/cmake /home/robot/robot_ros/catkin_ws/src/tensorflow_ros --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/robot/robot_ros/catkin_ws/devel/.private/tensorflow_ros -DCMAKE_INSTALL_PREFIX=/home/robot/robot_ros/catkin_ws/install; cd -

Is this related to ABI somehow? Any ideas how we might debug this? Thank you!!

peci1 commented 6 years ago

Try the new version, I had to force _pywrap_tensorflow_internal to be linked to the binaries, because it is left out by the linker since TF 1.5+ (or so).

That's because the library contains no directly used symbols from _pywrap_tensorflow_internal, but there are some globals that are needed, which the linker doesn't know.

So give it a try and let me know.

peci1 commented 6 years ago

And, moreover, if you're buulding TF yourself, you might consider not using the pip TF. New version of tensorflow_ros allows you to link against a custom build of TF.