We use tensorflow_cc
for Tensorflow C++ API. Use cmake
to build your project using tensorflow_cc
as library. Official page: link
Also see install-tensorflow for the official alternative (less prepared for use with CMake).
- Install dependencies (Ubuntu 18.04)
- Install dependencies (Ubuntu 14.04 and 16.04)
- Install tensorflow_cc (Ubuntu)
- Troubleshooting
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
sudo updatedb
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
sudo updatedb
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
You can create two diferent types of libraries: static or shared.
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 && sudo make install
Will create CMake target tensorflow_cc::Shared
.
- 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 && sudo make install
Intel CPU older than ivybridge:
export CC_OPT_FLAGS="-march=native"