wiki:Libs/Tensorflow

Tensorflow

A generalized computation graph framework from Google written in C++ (one big libtensorflow_framework.so runtime with parts of LLVM inside) with nice Python bindings and high-level APIs. Its runtime could be compared to a VM (or Octave's or Julia's runtime) given that it is highly optimized (C++) and could scale over multiple CPUs and GPUs on multiple nodes.

Tensorflow for Python is what Maxima was for Common Lisp.

To compile it from sources we must use the Bazel build tool (which is a crap that ruined the good-enough concept of just a running autoconf and a few standard environment variables, such as CFLAGS and LDFLAGS).

There is an a bazel's config file (which is mostly useless, because all the options are defined in individual BUILD files for each component).

Unfortunately Google got stuck with old g++ (and old Ubuntu 14.10) so tensorflow compiles in with -std=c++0x with optional -std=c++11 features.

build --action_env PYTHON_BIN_PATH="/usr/local/bin/python3"
build --action_env PYTHON_LIB_PATH="/usr/local/lib/python3.6/site-packages"
build --force_python=py3
build --host_force_python=py3
build --python_path="/usr/local/bin/python3"
build --define with_jemalloc=true
build --define with_gcp_support=true
build:hdfs --define with_hdfs_support=true
build:s3 --define with_s3_support=true
build:kafka --define with_kafka_support=true
build --define with_xla_support=true
build --define with_gdr_support=true
build:verbs --define with_verbs_support=true
build --action_env TF_NEED_OPENCL_SYCL="0"
build --action_env TF_NEED_CUDA="0"
build --define grpc_no_ares=true
#build:opt --copt=-D_FORTIFY_SOURCE=2
build:opt --copt=-fstack-protector-strong
build:opt --copt=-fstack-protector-all
build:opt --copt=--param
build:opt --copt=ssp-buffer-size=4
build:opt --copt=-Wstrict-aliasing=2
build:opt --copt=-fno-strict-aliasing
build:opt --copt=-D_FILE_OFFSET_BITS=64
build:opt --copt=-D_REENTRANT
build:opt --copt=-ffunction-sections
build:opt --copt=-fdata-sections
build:opt --copt=-m64
build:opt --copt=-march=native
build:opt --copt=-mtune=native
build:opt --copt=-O3
build:opt --copt=-fPIC
build:opt --copt=-pthread
#build:opt --copt=-fopenmp=libomp
#build:opt --copt=-stdlib=libc++
build:opt --cxxopt=-std=c++11
#build:opt --cxxopt=-stdlib=libc++
build:opt --copt=-I/usr/local/include
build:opt --host_copt=-march=native
build:opt --host_copt=-mtune=native
#build:opt --host_copt=-stdlib=libc++
build:opt --linkopt=-m64
build:opt --linkopt=-fPIC
build:opt --linkopt=-pthread
#build:opt --linkopt=-stdlib=libc++
#build:opt --linkopt=-rtlib=compiler-rt
#build:opt --linkopt=-fopenmp=libomp
build:opt --linkopt=-Wl,--gc-sections
build:opt --linkopt=-Wl,--as-needed
build:opt --linkopt=-Wl,-z,relro
build:opt --linkopt=-Wl,-z,now
build:opt --linkopt=-Wl,-z,noexecstack
build:opt --define with_default_optimizations=true
build --copt=-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK
build --host_copt=-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK

This is how to build and install

$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.6.0-py3-none-any.whl
Last modified 3 years ago Last modified on Mar 5, 2018, 10:09:56 AM
Note: See TracWiki for help on using the wiki.