Skip to content
Andrei Cramariuc edited this page Sep 6, 2018 · 1 revision

Q: Issues compiling tensorflow_ros_cpp

If your system uses the C++11 ABI (e.g. Ubuntu 16.04 or 18.04) then you must compile tensorflow from source, create a .whl file and pip install that in the virtual environment. Afterwards for tensorflow_cpp_ros to search for it you must compile with the following flag.

(segmappyenv)$ catkin build tensorflow_ros_cpp --cmake-args -DFORCE_TF_PIP_SEARCH="ON"

In some cases with multiple installations of tensorflow it is possible to point tensorflow_cpp_ros where to look with the following flags. Assuming the same paths as in the installation instructions are used the following information is still needed

# Python version
(segmappyenv)$ python --version

# Location of python library. From the list of highlighted files select the absolute
# path to the `.so` file which corresponds to the python version being used
(segmappyenv)$ ldconfig -p | grep libpython

Now from the following command replace with the values marked with <> obtained from above. In case the virtual environment is installed at a different location also remember to change the paths.

(segmappyenv)$ catkin build tensorflow_ros_cpp --cmake-args -DFORCE_TF_PIP_SEARCH="ON" \
    -DTF_PYTHON_VERSION="<PYTHON_VERSION>" \
    -DTF_PIP_PATH="$HOME/segmappyenv/lib/python<PYTHON_VERSION>/site-packages/tensorflow" \
    -DTF_PIP_EXECUTABLE="$HOME/segmappyenv/bin/pip" \
    -DTF_PYTHON_LIBRARY="<PATH_PYTHON_LIBRARY>"