Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模型不能在CPU上运行吗? #33

Open
zhouhao-learning opened this issue Jul 17, 2019 · 1 comment
Open

模型不能在CPU上运行吗? #33

zhouhao-learning opened this issue Jul 17, 2019 · 1 comment

Comments

@zhouhao-learning
Copy link

你好,我在测试的时候,由于环境的限制,我不得不改在CPU上运行,但是我更改了model.py中如下代码:

 def variable_on_device(self, name, shape, initializer):
        with tf.device('/cpu:0'):
            var = tf.get_variable(name=name, shape=shape, initializer=initializer)
        return var

然后运行我得到如下错误:

Traceback (most recent call last):
  File "tf_speech.py", line 27, in <module>
    re = X.speech_to_text('./test_voice/D4_750.wav')
  File "tf_speech.py", line 22, in speech_to_text
    res = bi_rnn.build_target_wav_file_test(wav_files, self.text_labels)
  File "/home/zh/sda2/sg-ai/Detox_AI/tf_recong/model.py", line 213, in build_target_wav_file_test
    self.init_session()
  File "/home/zh/sda2/sg-ai/Detox_AI/tf_recong/model.py", line 184, in init_session
    ckpt = tf.train.latest_checkpoint(self.savedir)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1805, in latest_checkpoint
    ckpt = get_checkpoint_state(checkpoint_dir, latest_filename)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1061, in get_checkpoint_state
    text_format.Merge(file_content, ckpt)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 536, in Merge
    descriptor_pool=descriptor_pool)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 590, in MergeLines
    return parser.MergeLines(lines, message)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 623, in MergeLines
    self._ParseOrMerge(lines, message)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 638, in _ParseOrMerge
    self._MergeField(tokenizer, message)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 763, in _MergeField
    merger(tokenizer, message, field)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 888, in _MergeScalarField
    value = tokenizer.ConsumeString()
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1251, in ConsumeString
    the_bytes = self.ConsumeByteString()
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1266, in ConsumeByteString
    the_list = [self._ConsumeSingleByteString()]
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_format.py", line 1291, in _ConsumeSingleByteString
    result = text_encoding.CUnescape(text[1:-1])
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_encoding.py", line 103, in CUnescape
    result = ''.join(_cescape_highbit_to_str[ord(c)] for c in result)
  File "/home/zh/sda3/Anaconda3/envs/deep2.0.0/lib/python3.6/site-packages/google/protobuf/text_encoding.py", line 103, in <genexpr>
    result = ''.join(_cescape_highbit_to_str[ord(c)] for c in result)
IndexError: list index out of range

请问我能怎么在CPU上运行呢?谢谢

@holidaystyle
Copy link

我现在遇到了同样的问题 请问你当时是怎么解决的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants