Tensorflow:在models.tutorials.rnn中使用reader_test.py运行错误

时间:2017-06-30 22:01:31

标签: tensorflow lstm

我在wind10中使用anaconda2和基于python 3.5的tensorflow-gpu环境。我通过run:

测试了tensorflow(v1.2)的安装
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

安装没有问题。

然后我通过运行两个提供的示例进一步测试它:

reader_test.py 
ptb_word_lm.py #this is to use LSTM to model penntree bank data

但这两个程序无法成功运行:

对于第一种情况: enter image description here

对于第二种情况:

#implementation in anaconda prompt
(tensorflow-gpu) D:\Research\Manuscript\Simplified LSTM\models-master\models-master\tutorials\rnn\ptb>python ptb_word_lm.py --data_path=D:\simple-examples\data

结果错误消息:

2017-06-30 18:06:05.819002: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-06-30 18:06:05.819089: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-30 18:06:05.819770: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-30 18:06:05.819816: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\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-06-30 18:06:05.819843: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\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-06-30 18:06:05.819866: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\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-06-30 18:06:05.819889: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\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-06-30 18:06:05.819911: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\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-06-30 18:06:06.317871: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:940] Found device 0 with properties:
name: GeForce 940M
major: 5 minor: 0 memoryClockRate (GHz) 1.176
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.66GiB
2017-06-30 18:06:06.317961: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:961] DMA: 0
2017-06-30 18:06:06.321380: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   Y
2017-06-30 18:06:06.322688: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce 940M, pci bus id: 0000:01:00.0)
WARNING:tensorflow:Standard services need a 'logdir' passed to the SessionManager
Epoch: 1 Learning rate: 1.000
2017-06-30 18:06:11.106452: E c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\stream_executor\cuda\cuda_blas.cc:365] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
2017-06-30 18:06:11.106573: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\stream_executor\stream.cc:1601] attempting to perform BLAS operation using StreamExecutor without BLAS support
Traceback (most recent call last):
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
    return fn(*args)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
    status, run_metadata)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\contextlib.py", line 66, in __exit__
    next(self.gen)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\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.InternalError: Blas GEMM launch failed : a.shape=(20, 400), b.shape=(400, 800), m=20, n=800, k=400
         [[Node: Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/concat, Model/RNN/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/read)]]
         [[Node: Train/Model/RNN/RNN/multi_rnn_cell/cell_1/cell_1/basic_lstm_cell/add_39/_123 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_6049_Train/Model/RNN/RNN/multi_rnn_cell/cell_1/cell_1/basic_lstm_cell/add_39", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ptb_word_lm.py", line 395, in <module>
    tf.app.run()
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "ptb_word_lm.py", line 381, in main
    verbose=True)
  File "ptb_word_lm.py", line 310, in run_epoch
    vals = session.run(fetches, feed_dict)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
    run_metadata_ptr)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 997, in _run
    feed_dict_string, options, run_metadata)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1132, in _do_run
    target_list, options, run_metadata)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Blas GEMM launch failed : a.shape=(20, 400), b.shape=(400, 800), m=20, n=800, k=400
         [[Node: Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/concat, Model/RNN/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/read)]]
         [[Node: Train/Model/RNN/RNN/multi_rnn_cell/cell_1/cell_1/basic_lstm_cell/add_39/_123 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_6049_Train/Model/RNN/RNN/multi_rnn_cell/cell_1/cell_1/basic_lstm_cell/add_39", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op 'Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/MatMul', defined at:
  File "ptb_word_lm.py", line 395, in <module>
    tf.app.run()
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "ptb_word_lm.py", line 357, in main
    m = PTBModel(is_training=True, config=config, input_=train_input)
  File "ptb_word_lm.py", line 157, in __init__
    (cell_output, state) = cell(inputs[:, time_step, :], state)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\rnn_cell_impl.py", line 180, in __call__
    return super(RNNCell, self).__call__(inputs, state)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\layers\base.py", line 441, in __call__
    outputs = self.call(inputs, *args, **kwargs)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\rnn_cell_impl.py", line 916, in call
    cur_inp, new_state = cell(cur_inp, cur_state)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\rnn_cell_impl.py", line 180, in __call__
    return super(RNNCell, self).__call__(inputs, state)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\layers\base.py", line 441, in __call__
    outputs = self.call(inputs, *args, **kwargs)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\rnn_cell_impl.py", line 383, in call
    concat = _linear([inputs, h], 4 * self._num_units, True)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\rnn_cell_impl.py", line 1021, in _linear
    res = math_ops.matmul(array_ops.concat(args, 1), weights)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\math_ops.py", line 1816, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 1217, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "C:\Users\Y L\Anaconda2\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in __init__
    self._traceback = _extract_stack()



InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(20, 400), b.shape=(400, 800), m=20, n=800, k=400
                 [[Node: Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](Train/Model/RNN/RNN/multi_rnn_cell/cell_0/cell_0/basic_lstm_cell/basic_lstm_cell/concat, Model/RNN/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/read)]]
                 [[Node: Train/Model/RNN/RNN/multi_rnn_cell/cell_1/cell_1/basic_lstm_cell/add_39/_123 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_6049_Train/Model/RNN/RNN/multi_rnn_cell/cell_1/cell_1/basic_lstm_cell/add_39", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

1 个答案:

答案 0 :(得分:0)

我通过更新anaconda(conda upate --all)然后重新启动PC解决了这个问题。