|
46 | 46 | "metadata.")
|
47 | 47 |
|
48 | 48 | # Model specific parameters
|
| 49 | +tf.flags.DEFINE_string( |
| 50 | + "master", default=None, |
| 51 | + help="GRPC URL of the master (e.g. grpc://ip.address.of.tpu:8470). You " |
| 52 | + "must specify either this flag or --tpu.") |
49 | 53 | tf.flags.DEFINE_string("data_dir", "",
|
50 | 54 | "Path to directory containing the MNIST dataset")
|
51 | 55 | tf.flags.DEFINE_string("model_dir", None, "Estimator model_dir")
|
@@ -132,11 +136,24 @@ def main(argv):
|
132 | 136 | del argv # Unused.
|
133 | 137 | tf.logging.set_verbosity(tf.logging.INFO)
|
134 | 138 |
|
135 |
| - tpu_cluster_resolver = tf.contrib.cluster_resolver.TPUClusterResolver( |
136 |
| - FLAGS.tpu, zone=FLAGS.tpu_zone, project=FLAGS.gcp_project) |
| 139 | + if FLAGS.master is None and FLAGS.tpu is None: |
| 140 | + raise RuntimeError('You must specify either --master or --tpu.') |
| 141 | + if FLAGS.master is not None: |
| 142 | + if FLAGS.tpu is not None: |
| 143 | + tf.logging.warn('Both --master and --tpu are set. Ignoring ' |
| 144 | + '--tpu and using --master.') |
| 145 | + tpu_grpc_url = FLAGS.master |
| 146 | + else: |
| 147 | + tpu_cluster_resolver = ( |
| 148 | + tf.contrib.cluster_resolver.TPUClusterResolver( |
| 149 | + FLAGS.tpu, |
| 150 | + zone=FLAGS.tpu_zone, |
| 151 | + project=FLAGS.gcp_project)) |
| 152 | + tpu_grpc_url = tpu_cluster_resolver.get_master() |
137 | 153 |
|
138 | 154 | run_config = tf.contrib.tpu.RunConfig(
|
139 |
| - cluster=tpu_cluster_resolver, |
| 155 | + master=tpu_grpc_url, |
| 156 | + evaluation_master=tpu_grpc_url, |
140 | 157 | model_dir=FLAGS.model_dir,
|
141 | 158 | session_config=tf.ConfigProto(
|
142 | 159 | allow_soft_placement=True, log_device_placement=True),
|
|
0 commit comments