From 16c202635e3cc18031078b82bca2089fc921213d Mon Sep 17 00:00:00 2001
From: "A. Unique TensorFlower" <gardener@tensorflow.org>
Date: Wed, 17 May 2017 06:19:30 -0700
Subject: [PATCH 1/3] internal change

PiperOrigin-RevId: 156299828
---
 .../tensorboard/components/tf_distribution_dashboard/BUILD     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD b/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD
index bff6ed6d7d8..38c3eb6c11f 100644
--- a/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD
+++ b/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD
@@ -59,5 +59,6 @@ tensorboard_ts_library(
     srcs = [],
     deps_mgmt = "off",
     runtime = "nodejs",
-    deps = ["//tensorflow/tensorboard/components:common_deps"],
+    # Don't list the common_deps here; a src-less ts_library re-exports them,
+    # and they are outside the package where the Fileset will be rooted.
 )

From eb937e62c54ffaa607283cfa9db1359e9a0b62fa Mon Sep 17 00:00:00 2001
From: "A. Unique TensorFlower" <gardener@tensorflow.org>
Date: Wed, 17 May 2017 07:45:25 -0700
Subject: [PATCH 2/3] Fixing issue with cuda configuration when cudnn.h located
 in /usr/include/cudnn.h

PiperOrigin-RevId: 156306372
---
 third_party/gpus/cuda_configure.bzl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl
index 6994db0a044..c6deae05b88 100644
--- a/third_party/gpus/cuda_configure.bzl
+++ b/third_party/gpus/cuda_configure.bzl
@@ -787,7 +787,7 @@ def _symlink_genrule_for_dir(repository_ctx, src_dir, dest_dir, genrule_name,
     if dest_files[i] != "":
       # If we have only one file to link we do not want to use the dest_dir, as
       # $(@D) will include the full path to the file.
-      dest = ' $(@D)/' + dest_dir + dest_files[i] if len(dest_files) != 1 else ' $(@D)' + dest_files[i]
+      dest = ' $(@D)/' + dest_dir + dest_files[i] if len(dest_files) != 1 else ' $(@D)/' + dest_files[i]
       command.append('ln -s ' + src_files[i] + dest)
       outs.append('      "' + dest_dir + dest_files[i] + '",')
   genrule = _genrule(src_dir, genrule_name, " && ".join(command),
@@ -875,8 +875,8 @@ def _create_cuda_repository(repository_ctx):
   included_files = _read_dir(repository_ctx, cuda_include_path).replace(
       cuda_include_path, '').splitlines()
   if '/cudnn.h' not in included_files:
-    genrules.append(_symlink_genrule_for_dir(repository_ctx, None, "",
-        "cudnn-include", [cudnn_header_dir + "/cudnn.h"], ["include/cudnn.h"]))
+    genrules.append(_symlink_genrule_for_dir(repository_ctx, None, "include/",
+        "cudnn-include", [cudnn_header_dir + "/cudnn.h"], ["cudnn.h"]))
   else:
     genrules.append(
             'filegroup(\n' +

From 9a47c258c9c2286ae2c14a0da6458055f3b691d3 Mon Sep 17 00:00:00 2001
From: Eugene Brevdo <ebrevdo@google.com>
Date: Wed, 17 May 2017 08:37:12 -0700
Subject: [PATCH 3/3] [TF cmake] Bugfix: lazy import of portpicker in
 test_util.

Also remove a test that relies on it from the cmake tests: tensor_array_ops_test.py

PiperOrigin-RevId: 156311187
---
 tensorflow/contrib/cmake/tf_tests.cmake  |  1 +
 tensorflow/python/framework/test_util.py | 12 +++++++++++-
 tensorflow/python/kernel_tests/BUILD     |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tensorflow/contrib/cmake/tf_tests.cmake b/tensorflow/contrib/cmake/tf_tests.cmake
index 2a51ab62d45..7da0a0cbe92 100644
--- a/tensorflow/contrib/cmake/tf_tests.cmake
+++ b/tensorflow/contrib/cmake/tf_tests.cmake
@@ -181,6 +181,7 @@ if (tensorflow_BUILD_PYTHON_TESTS)
       "${tensorflow_source_dir}/tensorflow/python/kernel_tests/cast_op_test.py"
       "${tensorflow_source_dir}/tensorflow/python/kernel_tests/string_to_number_op_test.py"
       "${tensorflow_source_dir}/tensorflow/python/kernel_tests/clip_ops_test.py"
+      "${tensorflow_source_dir}/tensorflow/python/kernel_tests/tensor_array_ops_test.py"  # Needs portpicker.
       # misc
       "${tensorflow_source_dir}/tensorflow/python/kernel_tests/variable_scope_test.py"
       "${tensorflow_source_dir}/tensorflow/python/kernel_tests/reshape_op_test.py"
diff --git a/tensorflow/python/framework/test_util.py b/tensorflow/python/framework/test_util.py
index 194d608a884..485bb3b109b 100644
--- a/tensorflow/python/framework/test_util.py
+++ b/tensorflow/python/framework/test_util.py
@@ -27,9 +27,14 @@ import tempfile
 import threading
 
 import numpy as np
-import portpicker
 import six
 
+try:
+  import portpicker  # pylint: disable=g-import-not-at-top
+except ImportError as _portpicker_import_error:
+  portpicker = None
+
+# pylint: disable=g-import-not-at-top
 from google.protobuf import descriptor_pool
 from google.protobuf import text_format
 
@@ -811,7 +816,12 @@ def create_local_cluster(num_workers, num_ps, protocol="grpc"):
     A tuple `(worker_servers, ps_servers)`.  `worker_servers` is a list
     of `num_workers` objects of type `tf.train.Server` (all running locally);
     and `ps_servers` is a list of `num_ps` objects of similar type.
+
+  Raises:
+    ImportError: if portpicker module was not found at load time
   """
+  if not portpicker:
+    raise _portpicker_import_error
   worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
   ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]
   cluster_dict = {
diff --git a/tensorflow/python/kernel_tests/BUILD b/tensorflow/python/kernel_tests/BUILD
index ab69b33cb12..56ebc796f91 100644
--- a/tensorflow/python/kernel_tests/BUILD
+++ b/tensorflow/python/kernel_tests/BUILD
@@ -1905,6 +1905,7 @@ cuda_py_test(
         "//tensorflow/python:tensor_array_ops",
         "//tensorflow/python:variables",
     ],
+    flaky = 1,  # create_local_cluster sometimes times out.
 )
 
 cuda_py_test(