我一直在使用TenserFlow教程中的RNN代码:https://www.tensorflow.org/tutorials/recurrent
原始的RNN代码在这里:https://github.com/tensorflow/models/blob/master/tutorials/rnn/ptb/ptb_word_lm.py
我将经过训练的RNN模型保存为“火车模型”
if FLAGS.save_path:
print("Saving model to %s." % FLAGS.save_path)
sv.saver.save(session, FLAGS.save_path, global_step=sv.global_step)
现在我正在尝试恢复已保存的模型并使用它运行其他测试
with tf.name_scope("Test"):
test_input = PTBInput(config=eval_config, data=test_data, name="TestInput")
with tf.variable_scope("Model", reuse=None, initializer=initializer):
mtest = PTBModel(is_training=False, config=eval_config,
input_=test_input)
save = tf.train.Saver()
with tf.Session() as session:
save.restore(session, tf.train.latest_checkpoint("./"))
test_perplexity = run_epoch(session, mtest)
似乎模型正确加载,但它挂在线上
vals = session.run(fetches, feed_dict)
在函数 run_epoch
中,当调用计算 test_perplexity
时 . CTRL-C
无法退出程序,并且GPU利用率为0%,因此很可能会阻止某些内容 .
任何帮助将不胜感激!
1 回答
尝试从源安装Tensorflow . 建议您使用,因为您可以为特定体系结构(GPU,CUDA,cuDNN)构建所需的Tensorflow二进制文件 .
这甚至被提到是提高Tensorflow性能的最佳实践之一 . 检查Tensorflow performance Guide . 同一个小摘录:
当您构建Tensorflow二进制文件的配置计算能力与GPU不同时,通常会出现您提到的问题 . 但是从源代码安装它可以让您选择配置特定的Compute Capability . 检查guide for installing from source .