TensorFlowCPU環境SSE / AVX / FMA命令セットのコンパイル



Tensorflow Cpu Environment Sse Avx Fma Instruction Set Compilation



Sess.run()は次のように表示されます警告

W tensorflow / core / platform / cpu_feature_guard.cc:45] TensorFlowライブラリはSSE4.1命令を使用するようにコンパイルされていませんが、これらはマシンで利用可能であり、CPU計算を高速化できます。
W tensorflow / core / platform / cpu_feature_guard.cc:45] TensorFlowライブラリはSSE4.2命令を使用するようにコンパイルされていませんが、これらはマシンで利用可能であり、CPU計算を高速化できます。
W tensorflow / core / platform / cpu_feature_guard.cc:45] TensorFlowライブラリはAVX命令を使用するようにコンパイルされていませんが、これらはマシンで利用可能であり、CPU計算を高速化できます。
W tensorflow / core / platform / cpu_feature_guard.cc:45] TensorFlowライブラリはAVX2命令を使用するようにコンパイルされていませんが、これらはマシンで利用可能であり、CPU計算を高速化できます。
W tensorflow / core / platform / cpu_feature_guard.cc:45] TensorFlowライブラリはFMA命令を使用するようにコンパイルされていませんが、これらはマシンで利用可能であり、CPU計算を高速化できます。

# Installing pf via pip install tensorflow may appear when sess.run() W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

つまり、マシンはこれらの命令セットをサポートしますが、TensorFlowはコンパイル時にこれらの命令セットを含まず、これらの命令セットに介入できるようにするには手動でコンパイルする必要があります。



# 1. Download the latest TensorFlow $ git clone https://github.com/tensorflow/tensorflow # 2. Install bazel # mac os $ brew install bazel # ubuntu $ sudo apt-get update && sudo apt-get install bazel # Windows $ choco install bazel # 3. Install TensorFlow Python dependencies # If you are using Anaconda this section can skip # mac os $ pip install six numpy wheel $ brew install coreutils # install coreutils for cuda $ sudo xcode-select -s /Applications/Xcode.app # set build tools # ubuntu sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel sudo apt-get install libcupti-dev # 4. Start compiling TensorFlow # 4.1 configure $ cd tensorflow # cd to the top-level directory created # configure When you want to choose something to support, here are recommended to choose N, no face will be wrong, if you support the graphics card, select y in cuda $ ./configure # configure # 4.2 bazel build # CUP-only $ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package # GPU support bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package # 4.3 Generating whl files bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg # 5 Install the newly compiled pip package # The official documentation used here is the sudo command. If it is a personal computer, it is not recommended to use sudo, directly pip. $ pip install /tmp/tensorflow_pkg/tensorflow-{version}-none-any.whl # 6 The next step is to verify that you have successfully installed. $ python -c 'import tensorflow as tf print(tf.Session().run(tf.constant('Hello, TensorFlow')))' # Then you will see the following output b'Hello, TensorFlow' # Congratulations, successfully compiled tensorflow, and Warning is also solved!

エラー解決

Do you wish to build TensorFlow with MKL support? [y/N] y MKL support will be enabled for TensorFlow Do you wish to download MKL LIB from the web? [Y/n] y Darwin is unsupported yet # MKL does not support Darwin (MAC), so choose N ERROR: /Users/***/Documents/tensorflow/tensorflow/core/BUILD:1331:1: C++ compilation of rule '//tensorflow/core:lib_hash_crc32c_accelerate_internal' failed: cc_wrapper.sh failed: error executing command external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 32 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. clang: error: no such file or directory: 'y' clang: error: no such file or directory: 'y' # Here is because some packages are not supported during configure but y is selected, so remember that all of them are selected n

参照

[1]: https://www.tensorflow.org/install/install_sources