使用笔记本连接谷歌云TPU的连接超时

问题描述 投票:0回答:1

我正在尝试使用BERT训练模型。对于BERT参数,我希望能够使用我自己的数据集微调参数。

我正在使用Google Cloud平台和TPU来加速培训过程。

我关注this教程刚刚替换了以下几行:

替换:

tf.estimator.Estimator(
model_fn=model_fn_par,
config=run_config_par,
params={"batch_size": BATCH_SIZE})

附:

tf.contrib.tpu.TPUEstimator(
model_fn=model_fn_par,
config = run_config_par,
use_tpu=FLAGS.use_tpu, train_batch_size = BATCH_SIZE,predict_batch_size=BATCH_SIZE)

取代:

run_config_par = tf.estimator.RunConfig(
model_dir=OUTPUT_DIR,
save_summary_steps=SAVE_SUMMARY_STEPS,
save_checkpoints_steps=SAVE_CHECKPOINTS_STEPS)

附:

run_config_par = tf.contrib.tpu.RunConfig(
master=master,
evaluation_master=master,
model_dir=FLAGS.model_dir,
session_config=tf.ConfigProto(
    allow_soft_placement=True, log_device_placement=True),
tpu_config=tf.contrib.tpu.TPUConfig(FLAGS.iterations,
                                    FLAGS.num_shards))

并定义了以下参数:

my_project = MY_PROJECT_NAME
my_zone = 'us-central1-b'
cluster_resolver = tf.contrib.cluster_resolver.TPUClusterResolver(
        tpu=[MY_TPU_NAME],
        zone=my_zone,
        project=my_project)
master = cluster_resolver.get_master()

在运行以下行时:

estimator_par.train(input_fn=train_input_fn_par, max_steps=num_train_steps)

笔记本试图连接到以下地址120次,但它没有成功,它返回超时错误:

Querying Tensorflow master (grpc://10.240.1.2:8470) for TPU system metadata.

我已创建并实例,如果您也将笔记本运行时类型设置为YOU。有人知道为什么我不能用笔记本连接到TPU吗?

tensorflow google-cloud-platform google-colaboratory google-cloud-tpu tpu
1个回答
1
投票

您是否从编辑>笔记本设置>硬件加速器中选择了TPU?

© www.soinside.com 2019 - 2024. All rights reserved.