Description: Upstream_3eb314bbcdc6e850eefc21c7ecbd91e28bd04a70_fix_old_CUDA_detection
 CUDA 8.0 has separate files for compute versions 2.0, 3.0, 3.5 and 5.0
 for libdevice.10.bc file.
 .
 Probing for one of them is sufficient.
 .
 python-tensorflow-cuda (1.7.1-1) unstable; urgency=medium
 .
   * New upstream release.
   * Bump minimum bazel build dep, wants >= 0.10.0.
   * Remove Fix_TensorRT_lib_version_detection patch.
   * Drop --config=tensorrt from bazel arguments, not needed anymore.
   * Does not build on Jessie/Xenial:
     https://github.com/tensorflow/tensorflow/issues/18039
   * Apply upstream 3eb314bbcdc6e850eefc21c7ecbd91e28bd04a70 to fix CUDA < 9
     detection.
Author: Adam Cecile <acecile@le-vert.net>

---
Origin: upstream, https://github.com/tensorflow/tensorflow/commit/3eb314bbcdc6e850eefc21c7ecbd91e28bd04a70
Bug: https://github.com/tensorflow/tensorflow/issues/17801
Forwarded: not-needed
Reviewed-By: TensorFlow upstream
Last-Update: 2018-08-29

--- python-tensorflow-cuda-1.7.1.orig/third_party/gpus/cuda_configure.bzl
+++ python-tensorflow-cuda-1.7.1/third_party/gpus/cuda_configure.bzl
@@ -96,6 +96,16 @@ NVVM_LIBDEVICE_PATHS = [
   "share/cuda/",
 ]
 
+# Files used to detect the NVVM libdevice path.
+NVVM_LIBDEVICE_FILES = [
+  # CUDA 9.0 has a single file.
+  "libdevice.10.bc",
+
+  # CUDA 8.0 has separate files for compute versions 2.0, 3.0, 3.5 and 5.0.
+  # Probing for one of them is sufficient.
+  "libdevice.compute_20.10.bc",
+]
+
 load(":download_clang.bzl", "download_clang")
 
 # TODO(dzc): Once these functions have been factored out of Bazel's
@@ -718,11 +728,11 @@ def _find_nvvm_libdevice_dir(repository_
     The path of the directory containing the CUDA headers.
   """
   cuda_toolkit_path = cuda_config.cuda_toolkit_path
-  for relative_path in NVVM_LIBDEVICE_PATHS:
-    if repository_ctx.path("%s/%slibdevice.10.bc" % (cuda_toolkit_path, relative_path)).exists:
-      return ("%s/%s" % (cuda_toolkit_path, relative_path))[:-1]
-  auto_configure_fail("Cannot find libdevice.10.bc under %s" % cuda_toolkit_path)
-
+  for libdevice_file in NVVM_LIBDEVICE_FILES:
+    for relative_path in NVVM_LIBDEVICE_PATHS:
+      if repository_ctx.path("%s/%s%s" % (cuda_toolkit_path, relative_path, libdevice_file)).exists:
+        return ("%s/%s" % (cuda_toolkit_path, relative_path))[:-1]
+  auto_configure_fail("Cannot find libdevice*.bc files under %s" % cuda_toolkit_path)
 
 def _cudart_static_linkopt(cpu_value):
   """Returns additional platform-specific linkopts for cudart."""
