tensorflow 中文语音识别问题

#####tensorflow-gpu 1.12 + python3.6 + thchs30语音包
在执行以下代码时报错:

def speech_to_text(wav_file):
    wav, sr = librosa.load(wav_file, mono=True)
    mfcc = np.transpose(np.expand_dims(librosa.feature.mfcc(wav, sr), axis=0), [0, 2, 1])

    logit = speech_to_text_network()

    saver = tf.train.Saver()
    with tf.Session() as sess:
        # 初始化
        sess.run(tf.global_variables_initializer())
        saver.restore(sess, tf.train.latest_checkpoint('./model'))

        decoded = tf.transpose(logit, perm=[1, 0, 2])
        decoded, _ = tf.nn.ctc_beam_search_decoder(decoded, sequence_len, merge_repeated=False)
        # predict = tf.sparse_to_dense(decoded[0].indices, decoded[0].shape, decoded[0].values) + 1
                # 执行到这一步的时候报错,
        output = sess.run(decoded, feed_dict={X: mfcc})
        print(output)
  • 报错信息
WARNING:tensorflow:From E:/jupyter_project/yuyin_04/train.py:175: calling expand_dims (from tensorflow.python.ops.array_ops) with dim is deprecated and will be removed in a future version.
Instructions for updating:
Use the `axis` argument instead
2020-06-16 14:23:26.447367: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-06-16 14:23:26.612799: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties: 
name: GeForce GTX 1660 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.59
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 4.92GiB
2020-06-16 14:23:26.612963: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2020-06-16 14:23:27.283154: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-06-16 14:23:27.283244: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0 
2020-06-16 14:23:27.283291: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N 
2020-06-16 14:23:27.283437: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4651 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1660 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5)
2020-06-16 14:23:32.282612: E tensorflow/stream_executor/cuda/cuda_dnn.cc:373] Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED
2020-06-16 14:23:32.283322: E tensorflow/stream_executor/cuda/cuda_dnn.cc:373] Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED
Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 1334, in _do_call
    return fn(*args)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 1319, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 1407, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
     [[{{node conv1d_0/conv1d/Conv2D}} = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](conv1d_0/conv1d/Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer, conv1d_0/conv1d/ExpandDims_1)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\framework\ops.py", line 5229, in get_controller
    yield g
  File "E:/jupyter_project/yuyin_04/train.py", line 317, in speech_to_text
    output = sess.run(decoded, feed_dict={X: mfcc})
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 929, in run
    run_metadata_ptr)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _run
    feed_dict_tensor, options, run_metadata)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 1328, in _do_run
    run_metadata)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\client\session.py", line 1348, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
     [[node conv1d_0/conv1d/Conv2D (defined at E:/jupyter_project/yuyin_04/train.py:133)  = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](conv1d_0/conv1d/Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer, conv1d_0/conv1d/ExpandDims_1)]]

Caused by op 'conv1d_0/conv1d/Conv2D', defined at:
  File "D:\Program Files\PyCharm 2019.3.3_pro\plugins\python\helpers\pydev\pydevd.py", line 2127, in <module>
    main()
  File "D:\Program Files\PyCharm 2019.3.3_pro\plugins\python\helpers\pydev\pydevd.py", line 2118, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\Program Files\PyCharm 2019.3.3_pro\plugins\python\helpers\pydev\pydevd.py", line 1427, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "D:\Program Files\PyCharm 2019.3.3_pro\plugins\python\helpers\pydev\pydevd.py", line 1434, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\Program Files\PyCharm 2019.3.3_pro\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:/jupyter_project/yuyin_04/train.py", line 324, in <module>
    speech_to_text(wav_file)
  File "E:/jupyter_project/yuyin_04/train.py", line 306, in speech_to_text
    logit = speech_to_text_network()
  File "E:/jupyter_project/yuyin_04/train.py", line 205, in speech_to_text_network
    out = conv1d_layer(input_tensor=X, size=1, dim=n_dim, activation='tanh', scale=0.14, bias=False)
  File "E:/jupyter_project/yuyin_04/train.py", line 133, in conv1d_layer
    out = tf.nn.conv1d(input_tensor, W, stride=1, padding='SAME') + (b if bias else 0)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\util\deprecation.py", line 553, in new_func
    return func(*args, **kwargs)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\util\deprecation.py", line 553, in new_func
    return func(*args, **kwargs)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 2471, in conv1d
    data_format=data_format)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 1044, in conv2d
    data_format=data_format, dilations=dilations, name=name)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\util\deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\framework\ops.py", line 3274, in create_op
    op_def=op_def)
  File "D:\ProgramData\Anaconda3\envs\python3.6\lib\site-packages\tensorflow\python\framework\ops.py", line 1770, in __init__
    self._traceback = tf_stack.extract_stack()

UnknownError (see above for traceback): Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
     [[node conv1d_0/conv1d/Conv2D (defined at E:/jupyter_project/yuyin_04/train.py:133)  = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](conv1d_0/conv1d/Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer, conv1d_0/conv1d/ExpandDims_1)]]


Process finished with exit code -1

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐