【Ubuntu-Tensorflow】InvalidArgumentError GPU不能使用的问题

问题内容如下
这里写图片描述

InvalidArgumentError (see above for traceback): Cannot assign a device to node 'train/final/fc3/b/Momentum': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices: 
ApplyMomentum: CPU 
Mul: CPU 
Sum: CPU 
Abs: CPU 
Const: CPU 
Assign: CPU 
Identity: CPU 
VariableV2: CPU 
     [[Node: train/final/fc3/b/Momentum = VariableV2[_class=["loc:@train/final/fc3/b"], container="", dtype=DT_FLOAT, shape=[29], shared_name="", _device="/device:GPU:0"]()]]

问题原因:有些tf.Variable()不允许在GPU运行,需要在CPU运行
解决办法:修改配置里面的allow_soft_placement=True,而allow_soft_placement=True,就是运行在出现不允许在GPU运行的时候,可以切换到CPU运行。

【2017/8/9】20:20
经过一个下午的不断的调试认证,发现,allow_soft_placement=True,就是在GPU跑不动程序的时候,自动切换到CPU运行,这种方式虽然能够确保程序的正常运行,但是却不能保证GPU出现问题能够及时的反馈,故而还是推荐使用allow_soft_placement=True的选项。

猜你喜欢

转载自blog.csdn.net/lgh0824/article/details/76981230