google 云 TPU 上的紧急错误

Panic error on google cloud TPU

我可以打开一个 ctpu 会话并从我的 git 存储库中获取我需要的代码,但是当我 运行 我的 tensorflow 代码来自云 shell 时,我收到一条消息说没有 TPU,我的程序崩溃了。这是我收到的错误消息:

adrien_doerig@adrien-doerig:~/capser$ python TPU_playground.py
(unset)
INFO:tensorflow:Querying Tensorflow master () for TPU system metadata.
2018-07-16 09:45:49.951310: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
INFO:tensorflow:Failed to find TPU: _TPUSystemMetadata(num_cores=0, num_hosts=0, num_of_cores_per_host=0, topology=None, devices=[_DeviceAttributes(/job:localhost/replica:0/task:0/device:CPU:0, CPU, 268435456)])
Traceback (most recent call last):
File "TPU_playground.py", line 79, in <module>
capser.train(input_fn=train_input_fn_tpu, steps=n_steps)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 363, in train
hooks.extend(self._convert_train_steps_to_hooks(steps, max_steps))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2068, in _convert_train_steps_to_hooks
if ctx.is_running_on_cpu():
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/tpu/python/tpu/tpu_context.py", line 339, in is_running_on_cpu
self._validate_tpu_configuration()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/tpu/python/tpu/tpu_context.py", line 525, in _validate_tpu_configuration
'are {}.'.format(tpu_system_metadata.devices))
RuntimeError: Cannot find any TPU cores in the system. Please double check Tensorflow master address and TPU worker(s). Available devices are [_DeviceAttributes(/job:localhost/replica:0/task:0/device:CPU

当我打开另一个 shell 并输入 "ctpu status" 时,我看到我的 tpu 集群是 运行ning,但我收到以下紧急错误:

adrien_doerig@capser-210106:~$ ctpu status

Your cluster is running!

    Compute Engine VM:  RUNNING
    Cloud TPU:          RUNNING

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x671b7e]
goroutine 1 [running]:
github.com/tensorflow/tpu/tools/ctpu/commands. 
(*statusCmd).Execute(0xc4200639e0, 0x770040, 0xc4200160d0, 0xc4200568a0, 0x0, 
0x0, 0x0, 0x6dddc0)
    /tmp/ctpu- 
release/src/github.com/tensorflow/tpu/tools/ctpu/commands/status.go:214 +0x5ce
github.com/google/subcommands.(*Commander).Execute(0xc420070000, 0x770040, 
0xc4200160d0, 0x0, 0x0, 0x0, 0x5)
    /tmp/ctpu-release/src/github.com/google/subcommands/subcommands.go:141 
+0x29f
github.com/google/subcommands.Execute(0x770040, 0xc4200160d0, 0x0, 0x0, 0x0, 
0xc420052700)
    /tmp/ctpu-release/src/github.com/google/subcommands/subcommands.go:385 
+0x5f
main.main()
    /tmp/ctpu-release/src/github.com/tensorflow/tpu/tools/ctpu/main.go:87 
+0xd5e

我尝试了此处建议的故障排除:https://cloud.google.com/tpu/docs/troubleshooting 但它没有用,因为当我进入

时一切似乎都很正常
gcloud compute tpus list

我也试过创建一个全新的项目,甚至使用不同的 google 帐户,但都没有解决问题。我还没有发现任何关于云 TPU 的类似错误。我是否遗漏了一些明显的东西?

感谢您的帮助!

好的,我明白了:

我需要按如下方式向我的 RunConfig 添加一个 master=... 参数(以下代码中的第 2 行):

my_tpu_run_config = tpu_config.RunConfig(
    master=TPUClusterResolver(tpu=[os.environ['TPU_NAME']]).get_master(),
    model_dir=FLAGS.model_dir,
    save_checkpoints_secs=FLAGS.save_checkpoints_secs,
    save_summary_steps=FLAGS.save_summary_steps,
    session_config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True),
    tpu_config=tpu_config.TPUConfig(iterations_per_loop=FLAGS.iterations, num_shards=FLAGS.num_shards))

现在,当我输入 'ctpu status'(我从另一个虚拟机不是 运行ning 的 shell 执行此操作)时,仍然会出现紧急错误,但我可以 运行 云的 TPU 上的东西,即我原来的 post 中的第一条错误消息不再出现。所以使用 master=... 参数允许我 运行 我的程序,但我仍然不确定恐慌错误意味着什么——它可能只是不重要。

ctpu中的panic暂时可以忽略,是由于没有检查Cloud TPU REST API返回的TPU Node对象中的SchedulingConfig字段是否失败导致的已填充(因此不是零)。这个 PR 解决了这个问题:

https://github.com/tensorflow/tpu/pull/148

一旦此 PR 合并到 Google Cloud Shell。

,噪音就会消失