def METHOD_NAME(vm):
  """Installs TensorFlow on the VM."""
  has_gpu = nvidia_driver.CheckNvidiaGpuExists(vm)
  tf_pip_package = (FLAGS.tf_gpu_pip_package if has_gpu else
                    FLAGS.tf_cpu_pip_package)
  if has_gpu:
    vm.METHOD_NAME('cuda_toolkit')
    vm.METHOD_NAME('nccl')
    vm.METHOD_NAME('cudnn')
  vm.METHOD_NAME('pip')
  vm.RemoteCommand('sudo pip install requests')
  vm.RemoteCommand('sudo pip install --upgrade absl-py')
  vm.RemoteCommand('sudo pip install --upgrade %s' % tf_pip_package)
  vm.RemoteCommand(
      'sudo pip install --upgrade %s' % FLAGS.t2t_pip_package)
  vm.InstallPackages('git')
  _, _, retcode = vm.RemoteHostCommandWithReturnCode(
      'test -d benchmarks', ignore_failure=True)
  if retcode != 0:
    vm.RemoteCommand(
        'git clone https://github.com/tensorflow/benchmarks.git')
  vm.RemoteCommand(
      'cd benchmarks && git checkout {}'.format(FLAGS.tf_cnn_benchmarks_branch)
  )
  if FLAGS.cloud == 'AWS' and FLAGS.tf_data_dir and (
      not FLAGS.tf_use_local_data):
    vm.METHOD_NAME('aws_credentials')