2017-05-12 63 views
2

我無法使Keras使用GPU版本的Tensorflow而不是CPU。每次我進口keras它只是說:使用GPU而不是CPU與Keras搭配使用Tensorflow後端的Linux

>>> import keras 
Using TensorFlow backend 

......這意味着它的工作,但在CPU上,而不是GPU。 我安裝CUDA和cuDNN和使用環境:

conda create -n tensorflow python=3.5 anaconda 

我覺得我第一次安裝tensorflow的CPU版本 - 我不記得了,因爲我整天剛開CUDA和cudnn工作。 不管怎樣,我安裝的是GPU版本太多:

pip install --ignore-installed --upgrade \ https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl 

,它仍然給出了同樣的消息。我試圖檢查正在使用的設備由下面的代碼:

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) 

,但我得到這個輸出,說明我使用的設備0,我的GPU:

2017-05-12 02:14:10.746679: 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-05-12 02:14:10.746735: 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-05-12 02:14:10.746751: 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-05-12 02:14:10.746764: 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-05-12 02:14:10.746777: 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. 
2017-05-12 02:14:10.926330: I 
tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] successful 
NUMA node read from SysFS had negative value (-1), but there must be 
at least one NUMA node, so returning NUMA node zero 
2017-05-12 02:14:10.926614: I 
tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 
with properties: 
name: GeForce GTX 1060 6GB 
major: 6 minor: 1 memoryClockRate (GHz) 1.7845 
pciBusID 0000:01:00.0 
Total memory: 5.93GiB 
Free memory: 5.51GiB 
2017-05-12 02:14:10.926626: I 
tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 
2017-05-12 02:14:10.926629: I 
tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y 
2017-05-12 02:14:10.926637: I 
tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating 
TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, 
pci bus id: 0000:01:00.0) 
Device mapping: 
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 
1060 6GB, pci bus id: 0000:01:00.0 
2017-05-12 02:14:10.949871: I 
tensorflow/core/common_runtime/direct_session.cc:257] Device mapping: 
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 
1060 6GB, pci bus id: 0000:01:00.0 

我真的跑出來的東西去做。我唯一剩下的就是卸載anaconda並重新安裝所有的東西,因爲我真的花了整整一天的時間使它和keras以及所有東西一起工作(只是沒有GPU),所以我真的不想這樣做。

+0

你能解決這個問題。我面對完全相同的問題? – rjmessibarca

回答

1

可能性是安裝具有默認選項的keras將安裝tensorflow的CPU版本。你可以卸載該版本,然後運行...

pip install --upgrade --no-deps keras 

https://github.com/fchollet/keras/issues/5766

+0

要求已更新:keras在 ./anaconda3/envs/tensorflow/lib/python3.5/site-packages - 如何卸載keras? sorrry我是新來的linux – Shooth

+0

好吧我卸載它,並重新安裝它使用你的鏈接,仍然沒有變化 – Shooth

+0

你卸載CPU版本的張量流? – MattMcKnight