Code Monkey home page Code Monkey logo

tensorflow-cpp's Introduction

TensorFlow CMake

This repository represents a fork of this repository. With some changes

  • Upgraded Tensorflow version
  • Removed binaries
  • Changed parameters for bazel build

This repository provides scripts for compiling and installing TensorFlow for C/C++ (headers + libraries) and CMake.

Maintainer: Jan Akhremchik

Overview

This repository provides TensorFlow libraries with the following specifications:

  • Provided versions: 1.14 (Default)
  • Supports Ubuntu 18.04 LTS (GCC >=7.4).
  • Provides variants Nvidia GPU.
  • GPU variants are built to support compute capabilities: 6.1, 7.0, 7.2, 7.5

NOTE: This repository does not include or bundle the source TensorFlow repository.

Install

First clone this repository:

git clone https://github.com/janchk/tensorflow-cpp.git

Eigen

To install the special version of Eigen requried by TensorFlow that we also bundle in this repository:

cd tensorflow/eigen
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_BUILD_TYPE=Release ..
make install -j{your core count}

NOTE: We recommend installing to ~/.local in order to prevent conflicts with other version of Eigen which may be installed via apt. Eigen exports its package during the build step, so CMake will default to finding the one we just installed unless a HINT is used or CMAKE_PREFIX_PATH is set to another location.

Protobuf

You could install protobuf by yourself following this instruction.

NOTE: You need to use version 3.7.1

As alternative you could use script build.sh in tensorflow-cpp/protobuf which installing protobuf system-wide

Abseil

Use this repository for installation.

NOTE: Install abseil AFTER tensorflow

TensorFlow

These are the options for using the TensorFlow CMake package:

Option 1 (Recommended): Installing into the (local) file system

cd tensorflow/tensorflow
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_BUILD_TYPE=Release ..
make install -j{your core count}

NOTE: The CMake will download all required sources for tensorflow and then build them.

Option 2 (Advanced): Create symbolic link to your target workspace directory:

ln -s /<SOURCE-PATH>/tensorflow/tensorflow <TARGET-PATH>/

Use

TensorFlow CMake can be included in other projects either using the find_package command:

...
find_package(TensorFlow CONFIG REQUIRED)
...

or alternatively included directly into other projects using the add_subdirectory command

...
add_subdirectory(/<SOURCE-PATH>/tensorflow/tensorflow)
...

NOTE: By default the CMake package will select the CPU-only variant of a given library version and defining/setting the TF_USE_GPU option variable reverts to the GPU-enabled variant.

User targets such as executables and libraries can now include the TensorFlow::TensorFlow CMake target using the target_link_libraries command.

add_executable(tf_hello src/main.cpp)
target_link_libraries(tf_hello PUBLIC TensorFlow::TensorFlow)
target_compile_features(tf_hello PRIVATE cxx_std_14)

NOTE: For more information on using CMake targets please refer to this excellent article.

Customize

If a specialized build of TensorFlow (e.g. different verion of CUDA, NVIDIA Compute Capability, AVX etc) is required, then the following steps can be taken:

  1. Follow the standard instructions for installing system dependencies.
    NOTE: For GPU-enabled systems, additional steps need to be taken.
  2. View and/or modify our utility script for step-by-step instructions for building, extracting and packaging all headers and libraries generated by Bazel from building TensorFlow.
  3. Set the TENSORFLOW_ROOT variable with the name of the resulting directory:
cmake -DTENSORFLOW_ROOT=~/.tensorflow/lib -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_BUILD_TYPE=Release ..

Common problems

  • error: 'int128' does not name a type; did you mean 'uint128'? - Try to reinstall abseil
  • libtensorflow_cc.so.1: cannot open shared object file: No such file or directory - Try sudo ldconfig

License

Apache License 2.0

tensorflow-cpp's People

Contributors

janchk avatar tomlankhorst avatar vastsoun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.