“完成运行local_init_op”后Tensorflow变慢

San*_*ani 5 python tensorflow tensorflow-estimator

我有一个来自 github 的基于 tensorflow 的代码,它非常慢。它甚至不打印(即使在为 tf.logging 启用调试模式之后)打印以下内容后发生的事情

信息:tensorflow:完成运行local_init_op。 --> 此行代码执行后需要 20 分钟 INFO:tensorflow:prediction_loop 标记为完成

有人可以告诉在哪里查看和优化吗?
已经检查了以下事项:

  • model_fn : 这在 local_init_op 之前执行
  • 本地文件:检查点文件从本地文件系统保存和加载。所以文件传输延迟不应该是原因
  • warm_start_from:尝试过。对预测时间没有影响

估算器代码:

estimator = tf.contrib.tpu.TPUEstimator(
      use_tpu=FLAGS.use_tpu,
      model_fn=model_fn,
      config=run_config,
      warm_start_from = tf.estimator.WarmStartSettings(
            ckpt_to_initialize_from='/content/ckpt',
        ),
      train_batch_size=FLAGS.train_batch_size,
      predict_batch_size=FLAGS.predict_batch_size)
Run Code Online (Sandbox Code Playgroud)

预测代码:

results = estimator.predict(
          predict_input_fn, yield_single_examples=True, checkpoint_path='/content/ckpt/model.ckpt-10949')
Run Code Online (Sandbox Code Playgroud)

执行这段代码所用的时间:

results = list(results)
Run Code Online (Sandbox Code Playgroud)