vixtor-qm / tf-cpp-sample

A CMake Project For TF Inference

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tf-cpp-sample

A CMake Project For TF Inference

Build TF from source as shared lib on Ubuntu Linux

  1. Install bazel

  2. Clone TF from repository

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow

The repo defaults to the master development branch. You can also checkout a release branch to build: git checkout branch_name # r1.9, r1.10, etc.

Configure the build Configure your system build by running the following at the root of your TensorFlow source tree:

./configure
  1. Build in C++ library mode:
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 --config=monolithic //tensorflow:libtensorflow_cc.so
  1. Download and build protocol buffers IMPORTANT: open tensorflow/workspace.bzl and check for protocol buffer version used in TF. Download and build the same version. It will conflict in other case. Install protobuf using checkinstall. Call
sudo ldconfig

to set update the library cache

  1. Build Eigen

  2. Build absl lib

  3. Set up headers and lib paths in CMakeLists.txt

  4. Build the project and have fun

About

A CMake Project For TF Inference


Languages

Language:C++ 67.0%Language:CMake 33.0%