web-dev-qa-db-ja.com

TensorFlowでコンパイルされていないCPU命令

MacBook Air:OSX El Capitan

ターミナル(python 3 tfpractice.py)でTensorFlowコードを実行すると、出力が返されるまでの待機時間が通常より長くなり、その後に次のエラーメッセージが表示されます。

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がこのpip3インストールで動作するようにしたいのですが。だから私は次のパスをたどりました:tensorflow/core/platform/cpu_feature_guard

ここでコードを編集する必要がありますか?または、これらの手順でTensorFlowをコンパイルする別の方法はありますか?

Sudo pip3 install tensorflowを使用してTensorFlowをインストールしました。

6
Fizics

[〜#〜]注[〜#〜]:これらはエラーメッセージではなく、単なる警告メッセージです。

TFパフォーマンスを最大化する最良の方法(良いコードを書くことを除いて!!)は、それを sources からコンパイルすることです

それを行うと、TFはさまざまなオプションを要求します。これらのオプションには、これらの指示のオプションも含まれます。

私自身の経験では、ソースからのコンパイルは平均してパフォーマンスが優れています。

GPUで実行できる集中的な処理を実行している場合は、それが待機時間を説明することもあります。 GPUサポートについては、pip3 install tensorflow-gpu

9
Ujjwal

これらは警告です。つまり、ソースからPCにテンソルフローを構築する方が速い場合があります。

ただし、それらを無効にする場合は、以下のコードを使用できます

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf

これで警告が消えます。 'TF_CPP_MIN_LOG_LEVEL'は、ロギングを担当するTensorflow環境変数を表します。また、Ubuntuを使用している場合は、以下のコードを使用できます

export TF_CPP_MIN_LOG_LEVEL=2 

これがお役に立てば幸いです。

4
user5368329

Opt引数を指定してbazelを使用してコンパイルすることもできます。

bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-msse4.1 --copt=-msse4.2 //tensorflow/tools/pip_package:build_pip_package

私はあなたがこの議論で何かを見つけることができると思います: TensorflowをSSE4.2およびAVX命令でコンパイルする方法?

幸運を!

2
Tai Christian