Sign inSign up

robloj/tensorflow-native

By robloj

•Updated almost 8 years ago

Tensorflow for native cpu instructions

Image
0

184

robloj/tensorflow-native repository overview

⁠TensorFlow native binary

Image allows to compile tensorflow⁠ from sources with native mode. Read more about native mode here⁠.

IMPORTANT: Native architecture selects the CPU to tune for at compilation time by determining the processor type of the compiling machine. Using -mtune=native will produce code optimized for the local machine under the constraints of the selected instruction set. Using -march=native will enable all instruction subsets supported by the local machine (hence the result might not run on different machines).

Check more documentation on github⁠.

⁠How to compile tensorflow with native mode?

Notice that compilation process is very long and can take even few hours!

When compilation will finish, you have to use image to copy compiled tensorflow into your local filesystem.

For compilation process you have to do steps:

⁠1. Run image
docker run --name tf2copy -it robloj/tensorflow-native

Notice, we run named container with name tf2copy.

Wait until compilation process is done. You should see logs similar to:

...

bazel-out/k8-opt/genfiles/external/protobuf_archive/src: warning: directory does not exist.
Target //tensorflow/tools/pip_package:build_pip_package up-to-date:
  bazel-bin/tensorflow/tools/pip_package/build_pip_package
INFO: Elapsed time: 9026.270s, Critical Path: 95.38s
INFO: 6801 processes: 6801 local.
INFO: Build completed successfully, 7502 total actions
Sun Aug 19 09:23:50 UTC 2018 : === Preparing sources in dir: /tmp/tmp.jbIBSPuSwb
/tensorflow-r1.10 /tensorflow-r1.10
/tensorflow-r1.10
Sun Aug 19 09:24:02 UTC 2018 : === Building wheel
warning: no files found matching '*.dll' under directory '*'
warning: no files found matching '*.lib' under directory '*'
warning: no files found matching '*.h' under directory 'tensorflow/include/tensorflow'
warning: no files found matching '*' under directory 'tensorflow/include/Eigen'
warning: no files found matching '*.h' under directory 'tensorflow/include/google'
warning: no files found matching '*' under directory 'tensorflow/include/third_party'
warning: no files found matching '*' under directory 'tensorflow/include/unsupported'
Sun Aug 19 09:24:21 UTC 2018 : === Output wheel file is in: /tmp/tensorflow_pkg
⁠2. Find container id

Open new terminal and type:

docker ps

Example result:

CONTAINER ID   IMAGE                    COMMAND       CREATED        STATUS       PORTS  NAMES
b4fef7c3adfd   centos-tensorflow-native "/bin/sh..."  5 seconds ago  Up 4 seconds        tf2copy

Your container id is b4fef7c3adfd

⁠3. Copy tensorflow wheel into your local filesystem

Finally you can copy tensorflow wheel:


CONTAINER_ID=b4fef7c3adfd
DEST_DIR=/tmp/output

docker cp $CONTAINER_ID:/tmp/tensorflow_pkg $DEST_DIR

Where:

  • $CONTAINER_ID - id copied from step 2
  • $DEST_DIR - destination directory for compiled tensorflow

As result you should have compiled tensorflow in your destination dir:

ls $DEST_DIR

tensorflow-1.10.0-cp36-cp36m-linux_x86_64.whl

Congratulation! You have wheel package and you can easily install it via pip.

Tag summary

Content type

Image

Digest

Size

752.6 MB

Last updated

almost 8 years ago

docker pull robloj/tensorflow-native