Skip to content

Install tensorflow_cc#

We use tensorflow_cc for Tensorflow C++ API. Use cmake to build your project using tensorflow_cc as library. Official page: FloopCZ/tensorflow_cc

Also see install-tensorflow for the official alternative (less prepared for use with CMake).

Install dependencies (Ubuntu 18.04)#

Download and install requirements.

sudo apt-get install build-essential curl git cmake unzip autoconf autogen automake libtool mlocate zlib1g-dev g++-7 python python3-numpy python3-dev python3-pip python3-wheel wget realpath

Install dependencies (Ubuntu 14.04 and 16.04)#

Download and install requirements.

sudo apt-get install build-essential curl git cmake unzip autoconf autogen automake libtool mlocate zlib1g-dev python python3-numpy python3-dev python3-pip python3-wheel wget realpath
Ubuntu 14.04 and 16.04 doesn´t allow GCC7 installation direcly, you should add ubuntu-toolchain-r/test repository to install.

sudo apt-get update -y && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update -y && \
sudo apt-get install gcc-7 g++-7 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 && \
sudo update-alternatives --config gcc

Install tensorflow_cc (Ubuntu)#

You can create two diferent types of libraries: Shared (recommended) or Static.

Shared library#

Will create CMake target tensorflow_cc::Shared, which we use in roboticslab-uc3m/vision (recommended).

  • Requires install bazel
  • Slower to build
  • GPU support
  • Full Tensorflow C++ API

Download and install:

git clone https://github.com/FloopCZ/tensorflow_cc.git
cd tensorflow_cc/tensorflow_cc
mkdir build && cd build
cmake -DTENSORFLOW_STATIC=OFF -DTENSORFLOW_SHARED=ON ..
make # No need for -j$(nproc), bazel will use all CPUs anyway
sudo make install

Static library#

Will create CMake target tensorflow_cc::Static.

  • Default
  • Faster to build
  • No GPU support
  • Basic functionalities

Download and install:

git clone https://github.com/FloopCZ/tensorflow_cc.git
cd tensorflow_cc/tensorflow_cc
mkdir build && cd build
cmake ..
make -j$(nproc)
sudo make install

Troubleshooting#

Note for Intel CPU older than ivybridge#

Intel CPU older than ivybridge:

export CC_OPT_FLAGS="-march=native"

Working setups#

Related: install-tensorflow#working-setups

tiago-entrenamiento#

Non-working setups#

Related: install-tensorflow#non-working-setups