2017-07-18 9 views
1

Linux上でテンソルフローバックエンドでケラスを実行しています。 、私は私が使用tensorflowがhttps://storage.googleapis.com/tensorflow/linux/gpu/tensorflow- 0.11.0-cp27-none-linux_x86_64.whlKerasテンソルフローバックエンドでGPUが検出されない

a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a') 
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b') 
c = tf.matmul(a, b) 
# Creates a session with log_device_placement set to True. 
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) 
# Runs the op. 
print(sess.run(c)) 
からだったなど、まず自身でtensorflow GPUのバージョンをインストールし、確認するには、次のコードを実行し、GPU上で実行していることが判明し、それが実行しているGPUを示し、デバイスマッピング

次に、conda install kerasを使用してケラをインストールしました。私はconda listをチェックしましたが、テンソルフロー(1.1.0と0.11.0)の2つのバージョンがあります。

2017-07-18 16:35:59.569535: 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. 
2017-07-18 16:35:59.569629: 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. 
2017-07-18 16:35:59.569690: 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. 
2017-07-18 16:35:59.569707: 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. 
2017-07-18 16:35:59.569731: 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. 
Device mapping: no known devices. 
2017-07-18 16:35:59.579959: I tensorflow/core/common_runtime/direct_session.cc:257] Device mapping: 

MatMul: (MatMul): /job:localhost/replica:0/task:0/cpu:0 
2017-07-18 16:36:14.369948: I tensorflow/core/common_runtime/simple_placer.cc:841] MatMul: (MatMul)/job:localhost/replica:0/task:0/cpu:0 
b: (Const): /job:localhost/replica:0/task:0/cpu:0 
2017-07-18 16:36:14.370051: I tensorflow/core/common_runtime/simple_placer.cc:841] b: (Const)/job:localhost/replica:0/task:0/cpu:0 
a: (Const): /job:localhost/replica:0/task:0/cpu:0 
2017-07-18 16:36:14.370109: I tensorflow/core/common_runtime/simple_placer.cc:841] a: (Const)/job:localhost/replica:0/task:0/cpu:0 

は、私はすでにkerasがインストールされる前に動作CUDA_VISIBLE_DEVICESを設定します。私は、その結果import tensorflow as tfを試してみました。 これはテンソルフローバージョンのためですか?ケラスをインストールするときに1.1.0の代わりに0.11.0をインストールすることはできますか? テンソルフローが原因でGPUが検出されない場合は、どうすればこの問題を解決できますか?私はこのlinkを読んで、テンソルフローが自動的にGPU上で実行されると言います。

+0

私は、 'pip install tensorflow-gpu'でテンソルフローを再度インストールすることで問題を解決することができました。ケラスGitHub発行:https://github.com/fchollet/keras/issues/5712 – matchifang

答えて

2

より新しいバージョンのTensorFlowによってKerasは古いGPU対応バージョン(tensorflow-gpu)を隠しているCPU専用のTensorFlowパッケージ(tensorflow)をインストールした可能性があります。

まず、GPU対応バージョンをアップグレードします。通常はpip install --upgrade tensorflow-gpuとすることができますが、TensorFlow installation pageにアナコンダ固有の手順があります。次に、pip uninstall tensorflowのCPU専用TensorFlowパッケージをアンインストールできます。今やimport tensorflow as tfはGPU対応のパッケージを実際にインポートする必要があります。あなたが提案するように、自動的にGPUを自動的に検出する必要があります。

関連する問題