Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 2.55 KB

TF_build_from_source_on_ubuntu.md

File metadata and controls

58 lines (38 loc) · 2.55 KB

build tensorflow commands

# build pip package
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

# build cc library
bazel build --config=opt --config=cuda //tensorflow:libtensorflow_cc.so

# build c library
bazel build --config=opt --config=cuda //tensorflow:libtensorflow.so

links of build tensorflow c++ library

building parameters

--config=monolithic

  • build only ONE library libtensorflow_cc.so
  • stackoverflow
  • DO NOT use --config=monolithic unless you don't need custom op

build pip package succeed but tf.Session() failed

  • DO Not install built pip package in source code folder, install it in ~ is OK [Not Sure reason]

build AI library on Linux

TensorBlock.h:393:35: error: parse error in template argument list

No session factory registered

build custom op on Linux

-D_GLIBCXX_USE_CXX11_ABI=0

  • The binary pip packages available on the TensorFlow website are built with gcc4 that uses the older ABI. If you compile your op library with gcc>=5, add -D_GLIBCXX_USE_CXX11_ABI=0 to the command line to make the library compatible with the older abi. tensorflow
    • compile simple custom op library libzero_out.so using gcc with pip package from tf website, -D_GLIBCXX_USE_CXX11_ABI=0 need to be set.
    • compile simple custom op library libzero_out.so using gcc with self-built pip package, DO NOT set D_GLIBCXX_USE_CXX11_ABI=0, and in this situation, c++ code can call the custom op library with TF_LoadLibrary