Repository: tensorflow/tensor2tensor

Issue:
Dependency mismatch for Cloud ML Engine runtime 1.12
### Description
TensorFlow Probability has just released 0.6.0 to PyPI, which expects TF 1.13.1.  The current Runtime Version on Cloud ML Engine comes with TF 1.12.0.  Without either:
1. upgrading the default tensorflow version to 1.13.1 on ML Engine, or
2. downgrading the version of tensorflow-probability to 0.5.0,
jobs cannot currently be submitted to ML Engine.

FWIW, I already tried specifying both of these in the requirements.txt file of my t2t_usr_dir package with no change in error output, so I'm assuming these requirements.txt are superseded by the versions imposed by PyPI.

### Environment information
Cloud ML Engine Runtime Version 1.12

### For bugs: reproduction and error logs

#### Steps to reproduce:
Submit any `t2t-trainer` job to Cloud ML Engine.

#### Error logs:
```
The replica master 0 exited with a non-zero status of 1. 
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/.local/lib/python3.5/site-packages/tensor2tensor/bin/t2t_trainer.py", line 24, in <module>
    from tensor2tensor import models  # pylint: disable=unused-import
  File "/root/.local/lib/python3.5/site-packages/tensor2tensor/models/__init__.py", line 25, in <module>
    from tensor2tensor.layers import modalities  # pylint: disable=g-import-not-at-top
  File "/root/.local/lib/python3.5/site-packages/tensor2tensor/layers/modalities.py", line 22, in <module>
    from tensor2tensor.layers import common_attention
  File "/root/.local/lib/python3.5/site-packages/tensor2tensor/layers/common_attention.py", line 31, in <module>
    from tensor2tensor.layers import common_layers
  File "/root/.local/lib/python3.5/site-packages/tensor2tensor/layers/common_layers.py", line 30, in <module>
    import tensorflow_probability as tfp
  File "/root/.local/lib/python3.5/site-packages/tensorflow_probability/__init__.py", line 68, in <module>
    _ensure_tf_install()
  File "/root/.local/lib/python3.5/site-packages/tensorflow_probability/__init__.py", line 65, in _ensure_tf_install
    present=tf.__version__))
ImportError: This version of TensorFlow Probability requires TensorFlow version >= 1.13.1; Detected an installation of version 1.12.0. Please upgrade TensorFlow to proceed.
```



Discussion:
Current workaround is to hardcode `tensorflow-probability==0.5.0` in `setup.py` and install tensor2tensor from source locally before sending the job to ML Engine.  Given no currently scheduled release date for runtime version 1.13 ML Engine, this doesn't seem like a satisfactory solution.
I resolved the issue on my local install by downgrading tensor2tensor (`pip install tensor2tensor==1.8.0`)

Resolving patch:
diff --git a/tensor2tensor/data_generators/wikisum/parallel_launch.py b/tensor2tensor/data_generators/wikisum/parallel_launch.py
--- a/tensor2tensor/data_generators/wikisum/parallel_launch.py
+++ b/tensor2tensor/data_generators/wikisum/parallel_launch.py
@@ -146,7 +146,7 @@ def create_instance(instance_name, cpu=1, mem=4):
 
 
 def list_vm_names_and_ips():
-  list_out = cloud.shell_output(cloud.Gcloud.LIST_VM)
+  list_out = cloud.shell_output(cloud.LIST_VM)
   lines = [l.split() for l in list_out.split("\n")[1:-1]]
   names_and_ips = [(l[0].strip(), l[-2].strip()) for l in lines]
   return names_and_ips
diff --git a/tensor2tensor/utils/cloud_mlengine.py b/tensor2tensor/utils/cloud_mlengine.py
--- a/tensor2tensor/utils/cloud_mlengine.py
+++ b/tensor2tensor/utils/cloud_mlengine.py
@@ -35,55 +35,10 @@
 FLAGS = tf.flags.FLAGS
 
 CONSOLE_URL = "https://console.cloud.google.com/mlengine/jobs/"
-RUNTIME_VERSION = "1.12"
-
-
-class Gcloud(object):
-  """gcloud command strings."""
-  # Note these can be modified by set_versions
-  VM_VERSION = "tf-1-12"
-  TPU_VERSION = "1.12"
-
-  @classmethod
-  def set_versions(cls, vm, tpu):
-    cls.VM_VERSION = vm
-    cls.TPU_VERSION = tpu
-
-  @classmethod
-  def create_vm(cls):
-    create_vm_str = """
-    gcloud compute instances create {name} \
-      --machine-type=n1-standard-8 \
-      --image-family=%s \
-      --image-project=ml-images \
-      --scopes=https://www.googleapis.com/auth/cloud-platform
-    """ % cls.VM_VERSION
-    return create_vm_str
-
-  DELETE_VM = "gcloud compute instances delete {name} --quiet"
-
-  @classmethod
-  def create_tpu(cls):
-    create_tpu_str = """
-    gcloud beta compute tpus create \
-      {name} \
-      --range={tpu_ip}/29 \
-      --version=%s
-    """ % cls.TPU_VERSION
-    return create_tpu_str
-
-  DELETE_TPU = "gcloud beta compute tpus delete {name} --quiet"
-
-  LIST_TPU = "gcloud beta compute tpus list"
-  LIST_VM = "gcloud compute instances list"
-
-  SSH_LOCAL_PORT_FORWARD = "-L {local_port}:{host}:{remote_port}"
-  SSH_TUNNEL = """
-  gcloud compute ssh {name} -- -N
-  """
-
-  DEFAULT_PROJECT = "gcloud config get-value project"
-  DEFAULT_REGION = "gcloud config get-value compute/region"
+RUNTIME_VERSION = "1.13"
+LIST_VM = "gcloud compute instances list"
+DEFAULT_PROJECT = "gcloud config get-value project"
+DEFAULT_REGION = "gcloud config get-value compute/region"
 
 
 def shell_output(cmd_, **kwargs):
@@ -99,11 +54,11 @@ def format_cmd(cmd_, **kwargs):
 
 
 def default_region():
-  return shell_output(Gcloud.DEFAULT_REGION).strip()
+  return shell_output(DEFAULT_REGION).strip()
 
 
 def default_project():
-  return shell_output(Gcloud.DEFAULT_PROJECT).strip()
+  return shell_output(DEFAULT_PROJECT).strip()
 
 
 def get_setup_file(name, packages=None):


Test patch: