tflearn在使用gpu时抛出错误

时间:2017-09-22 08:10:22

标签: python tensorflow tensorflow-gpu tflearn

当我尝试在我的项目中使用with tf.device('/gpu:0'):时,它会抛出下面显示的错误。我安装了tensorflow-gpu。

代码:

def main():
    with tf.device('/gpu:0'):
        model = cnn_model.googlenet(WIDTH, HEIGHT, 3, LR, output=8,model_name=MODEL_NAME)
        model.fit({'input': batch_x}, {'targets': batch_y}, n_epoch=1,snapshot_step=2500, show_metric=True, run_id=MODEL_NAME)

cnn_model可以在这里找到:https://github.com/MrGrimod/gta_self_driving/blob/master/model/cnn_model.py

错误:

WARNING:tensorflow:From 
C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-        
packages\tensorflow\python\util\tf_should_use.py:175:         
initialize_all_variables (from tensorflow.python.ops.variables) is 
deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use `tf.global_variables_initializer` instead.
hdf5 is not supported on this machine (please install/reinstall h5py for 
optimal experience)
curses is not supported on this machine (please install/reinstall curses for 
an optimal experience)
Traceback (most recent call last):
File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
packages\tensorflow\python\client\session.py", line 1327, in _do_call
return fn(*args)
File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
packages\tensorflow\python\client\session.py", line 1297, in _run_fn
self._extend_graph()
File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
packages\tensorflow\python\client\session.py", line 1358, in _extend_graph
self._session, graph_def.SerializeToString(), status)

File
"C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\contextlib.py"
, line 88, in __exit__
next(self.gen)
 File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
packages\tensorflow\python\framework\errors_impl.py", line 466, in 
raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 
'init_3/NoOp': Unknown input node '^is_training/Assign'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "train.py", line 57, in <module>
    main()
  File "train.py", line 26, in main
    model = cnn_model.googlenet(WIDTH, HEIGHT, 3, LR, output=8, 
model_name=MODEL_NAME)
  File "C:\Users\MrGrimod\Desktop\gta_self_driving\model\cnn_model.py", line 
147, in googlenet
    max_checkpoints=0, tensorboard_verbose=0,tensorboard_dir='log')
  File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
 packages\tflearn\models\dnn.py", line 65, in __init__
    best_val_accuracy=best_val_accuracy)
  File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
 packages\tflearn\helpers\trainer.py", line 170, in __init__
    self.session.run(init)
  File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
 packages\tensorflow\python\client\session.py", line 895, in run
     run_metadata_ptr)
   File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
 packages\tensorflow\python\client\session.py", line 1124, in _run
     feed_dict_tensor, options, run_metadata)
  File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
  packages\tensorflow\python\client\session.py", line 1321, in _do_run
     options, run_metadata)
   File "C:\Users\MrGrimod\AppData\Local\Programs\Python\Python36\lib\site-
packages\tensorflow\python\client\session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 
 'init_3/NoOp': Unknown input node '^is_training/Assign'
2017-09-22 09:59:42.453552: W C:\tf_jenkins\home\workspace\rel-
win\M\windows\PY\36\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-09-22 09:59:42.453565: W C:\tf_jenkins\home\workspace\rel-
win\M\windows\PY\36\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.

1 个答案:

答案 0 :(得分:0)

通过使用TensorFlow中的this手册卸载所有内容然后安装所有内容来解决问题。

添加以下代码:tflearn.init_graph()