aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/gpus
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-05-05 08:36:05 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-05-05 09:41:47 -0700
commit8bf6ef1337359993a8be057c0dc90da8f5a6e4fa (patch)
treec7367050bf36d6f4b17a93d06700dc7169012ac1 /third_party/gpus
parent931e848c28e97e8cae410af242f8e09d75663ee4 (diff)
Merge changes from github.
Change: 121586635
Diffstat (limited to 'third_party/gpus')
-rw-r--r--third_party/gpus/crosstool/BUILD14
-rw-r--r--third_party/gpus/crosstool/CROSSTOOL92
-rwxr-xr-xthird_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc2
-rw-r--r--third_party/gpus/cuda/BUILD87
-rwxr-xr-xthird_party/gpus/cuda/cuda_config.sh99
-rw-r--r--third_party/gpus/cuda/platform.bzl59
6 files changed, 282 insertions, 71 deletions
diff --git a/third_party/gpus/crosstool/BUILD b/third_party/gpus/crosstool/BUILD
index eac4dc7fad..7c9c8ab884 100644
--- a/third_party/gpus/crosstool/BUILD
+++ b/third_party/gpus/crosstool/BUILD
@@ -22,6 +22,20 @@ cc_toolchain(
supports_param_files = 0,
)
+cc_toolchain(
+ name = "cc-compiler-darwin",
+ all_files = ":empty",
+ compiler_files = ":empty",
+ cpu = "darwin",
+ dwp_files = ":empty",
+ dynamic_runtime_libs = [":empty"],
+ linker_files = ":empty",
+ objcopy_files = ":empty",
+ static_runtime_libs = [":empty"],
+ strip_files = ":empty",
+ supports_param_files = 0,
+)
+
filegroup(
name = "empty",
srcs = [],
diff --git a/third_party/gpus/crosstool/CROSSTOOL b/third_party/gpus/crosstool/CROSSTOOL
index a9f26f5710..8db81a9603 100644
--- a/third_party/gpus/crosstool/CROSSTOOL
+++ b/third_party/gpus/crosstool/CROSSTOOL
@@ -150,3 +150,95 @@ toolchain {
}
linking_mode_flags { mode: DYNAMIC }
}
+
+toolchain {
+ abi_version: "local"
+ abi_libc_version: "local"
+ builtin_sysroot: ""
+ compiler: "compiler"
+ host_system_name: "local"
+ needsPic: true
+ target_libc: "macosx"
+ target_cpu: "darwin"
+ target_system_name: "local"
+ toolchain_identifier: "local_darwin"
+
+ tool_path { name: "ar" path: "/usr/bin/libtool" }
+ tool_path { name: "compat-ld" path: "/usr/bin/ld" }
+ tool_path { name: "cpp" path: "/usr/bin/cpp" }
+ tool_path { name: "dwp" path: "/usr/bin/dwp" }
+ tool_path { name: "gcc" path: "clang/bin/crosstool_wrapper_driver_is_not_gcc" }
+ cxx_flag: "-std=c++11"
+ ar_flag: "-static"
+ ar_flag: "-s"
+ ar_flag: "-o"
+ linker_flag: "-lc++"
+ linker_flag: "-undefined"
+ linker_flag: "dynamic_lookup"
+ # TODO(ulfjack): This is wrong on so many levels. Figure out a way to auto-detect the proper
+ # setting from the local compiler, and also how to make incremental builds correct.
+ cxx_builtin_include_directory: "/"
+ tool_path { name: "gcov" path: "/usr/bin/gcov" }
+ tool_path { name: "ld" path: "/usr/bin/ld" }
+ tool_path { name: "nm" path: "/usr/bin/nm" }
+ tool_path { name: "objcopy" path: "/usr/bin/objcopy" }
+ objcopy_embed_flag: "-I"
+ objcopy_embed_flag: "binary"
+ tool_path { name: "objdump" path: "/usr/bin/objdump" }
+ tool_path { name: "strip" path: "/usr/bin/strip" }
+
+ # Anticipated future default.
+ unfiltered_cxx_flag: "-no-canonical-prefixes"
+ # Make C++ compilation deterministic. Use linkstamping instead of these
+ # compiler symbols.
+ unfiltered_cxx_flag: "-Wno-builtin-macro-redefined"
+ unfiltered_cxx_flag: "-D__DATE__=\"redacted\""
+ unfiltered_cxx_flag: "-D__TIMESTAMP__=\"redacted\""
+ unfiltered_cxx_flag: "-D__TIME__=\"redacted\""
+
+ # Security hardening on by default.
+ # Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.
+ compiler_flag: "-D_FORTIFY_SOURCE=1"
+ compiler_flag: "-fstack-protector"
+
+ # Enable coloring even if there's no attached terminal. Bazel removes the
+ # escape sequences if --nocolor is specified.
+ compiler_flag: "-fcolor-diagnostics"
+
+ # All warnings are enabled. Maybe enable -Werror as well?
+ compiler_flag: "-Wall"
+ # Enable a few more warnings that aren't part of -Wall.
+ compiler_flag: "-Wthread-safety"
+ compiler_flag: "-Wself-assign"
+
+ # Keep stack frames for debugging, even in opt mode.
+ compiler_flag: "-fno-omit-frame-pointer"
+
+ # Anticipated future default.
+ linker_flag: "-no-canonical-prefixes"
+
+ compilation_mode_flags {
+ mode: DBG
+ # Enable debug symbols.
+ compiler_flag: "-g"
+ }
+ compilation_mode_flags {
+ mode: OPT
+ # No debug symbols.
+ # Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or even generally?
+ # However, that can't happen here, as it requires special handling in Bazel.
+ compiler_flag: "-g0"
+
+ # Conservative choice for -O
+ # -O3 can increase binary size and even slow down the resulting binaries.
+ # Profile first and / or use FDO if you need better performance than this.
+ compiler_flag: "-O2"
+
+ # Disable assertions
+ compiler_flag: "-DNDEBUG"
+
+ # Removal of unused code and data at link time (can this increase binary size in some cases?).
+ compiler_flag: "-ffunction-sections"
+ compiler_flag: "-fdata-sections"
+ }
+}
diff --git a/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc b/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
index 04ab50ca86..5f175efcf3 100755
--- a/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
+++ b/third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python2.7
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/third_party/gpus/cuda/BUILD b/third_party/gpus/cuda/BUILD
index 28b49b8cc7..792dbb4268 100644
--- a/third_party/gpus/cuda/BUILD
+++ b/third_party/gpus/cuda/BUILD
@@ -1,10 +1,11 @@
licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like
load("//tensorflow:tensorflow.bzl", "if_cuda")
-load("//tensorflow/core:platform/default/build_config.bzl",
- "tf_get_cuda_version",
- "tf_get_cudnn_version",
- )
+load("platform", "cuda_library_path")
+load("platform", "cuda_static_library_path")
+load("platform", "cudnn_library_path")
+load("platform", "cupti_library_path")
+load("platform", "readlink_command")
package(default_visibility = ["//visibility:public"])
@@ -31,6 +32,12 @@ config_setting(
},
)
+config_setting(
+ name = "darwin",
+ values = {"cpu": "darwin"},
+ visibility = ["//visibility:public"],
+)
+
cc_library(
name = "cuda_headers",
hdrs = glob([
@@ -43,24 +50,26 @@ cc_library(
cc_library(
name = "cudart_static",
srcs = [
- "lib64/libcudart_static.a",
+ cuda_static_library_path("cudart"),
],
includes = ["include/"],
linkopts = [
"-ldl",
- "-lrt",
"-lpthread",
- ],
+ ] + select({
+ "//tensorflow:darwin": [],
+ "//conditions:default": ["-lrt"]
+ }),
visibility = ["//visibility:public"],
)
cc_library(
name = "cudart",
srcs = [
- "lib64/libcudart.so" + tf_get_cuda_version(),
+ cuda_library_path("cudart")
],
data = [
- "lib64/libcudart.so" + tf_get_cuda_version(),
+ cuda_library_path("cudart")
],
includes = ["include/"],
visibility = ["//visibility:public"],
@@ -70,10 +79,10 @@ cc_library(
cc_library(
name = "cublas",
srcs = [
- "lib64/libcublas.so" + tf_get_cuda_version(),
+ cuda_library_path("cublas")
],
data = [
- "lib64/libcublas.so" + tf_get_cuda_version(),
+ cuda_library_path("cublas")
],
includes = ["include/"],
visibility = ["//visibility:public"],
@@ -83,10 +92,10 @@ cc_library(
cc_library(
name = "cudnn",
srcs = [
- "lib64/libcudnn.so" + tf_get_cudnn_version(),
+ cudnn_library_path()
],
data = [
- "lib64/libcudnn.so" + tf_get_cudnn_version(),
+ cudnn_library_path()
],
includes = ["include/"],
visibility = ["//visibility:public"],
@@ -96,10 +105,10 @@ cc_library(
cc_library(
name = "cufft",
srcs = [
- "lib64/libcufft.so" + tf_get_cuda_version(),
+ cuda_library_path("cufft")
],
data = [
- "lib64/libcufft.so" + tf_get_cuda_version(),
+ cuda_library_path("cufft")
],
includes = ["include/"],
visibility = ["//visibility:public"],
@@ -130,7 +139,7 @@ cc_library(
cc_library(
name = "cupti_dsos",
data = [
- "extras/CUPTI/lib64/libcupti.so" + tf_get_cuda_version(),
+ cupti_library_path(),
],
visibility = ["//visibility:public"],
)
@@ -152,34 +161,34 @@ genrule(
"include/cublas.h",
"include/cudnn.h",
"extras/CUPTI/include/cupti.h",
- "lib64/libcudart_static.a",
- "lib64/libcublas.so" + tf_get_cuda_version(),
- "lib64/libcudnn.so" + tf_get_cudnn_version(),
- "lib64/libcudart.so" + tf_get_cuda_version(),
- "lib64/libcufft.so" + tf_get_cuda_version(),
- "extras/CUPTI/lib64/libcupti.so" + tf_get_cuda_version(),
+ cuda_static_library_path("cudart"),
+ cuda_library_path("cublas"),
+ cudnn_library_path(),
+ cuda_library_path("cudart"),
+ cuda_library_path("cufft"),
+ cupti_library_path(),
],
cmd = if_cuda(
# Under cuda config, create all the symbolic links to the actual cuda files
- "OUTPUTDIR=`readlink -f $(@D)/../../..`; cd `dirname $(location :cuda_config.sh)`; OUTPUTDIR=$$OUTPUTDIR ./cuda_config.sh --check;",
+ "OUTPUTDIR=`{} -f $(@D)/../../..`; cd third_party/gpus/cuda; OUTPUTDIR=$$OUTPUTDIR ./cuda_config.sh --check;".format(readlink_command()),
# Under non-cuda config, create all dummy files to make the build go through
";".join([
- "mkdir -p $(@D)/include",
- "mkdir -p $(@D)/lib64",
- "mkdir -p $(@D)/extras/CUPTI/include",
- "mkdir -p $(@D)/extras/CUPTI/lib64",
- "touch $(@D)/include/cuda.h",
- "touch $(@D)/include/cublas.h",
- "touch $(@D)/include/cudnn.h",
- "touch $(@D)/extras/CUPTI/include/cupti.h",
- "touch $(@D)/lib64/libcudart_static.a",
- "touch $(@D)/lib64/libcublas.so" + tf_get_cuda_version(),
- "touch $(@D)/lib64/libcudnn.so" + tf_get_cudnn_version(),
- "touch $(@D)/lib64/libcudart.so" + tf_get_cuda_version(),
- "touch $(@D)/lib64/libcufft.so" + tf_get_cuda_version(),
- "touch $(@D)/extras/CUPTI/lib64/libcupti.so" + tf_get_cuda_version(),
- ]),
+ "mkdir -p $(@D)/include",
+ "mkdir -p $(@D)/lib64",
+ "mkdir -p $(@D)/extras/CUPTI/include",
+ "mkdir -p $(@D)/extras/CUPTI/lib64",
+ "touch $(@D)/include/cuda.h",
+ "touch $(@D)/include/cublas.h",
+ "touch $(@D)/include/cudnn.h",
+ "touch $(@D)/extras/CUPTI/include/cupti.h",
+ "touch $(@D)/{}".format(cuda_static_library_path("cudart")),
+ "touch $(@D)/{}".format(cuda_library_path("cublas")),
+ "touch $(@D)/{}".format(cudnn_library_path()),
+ "touch $(@D)/{}".format(cuda_library_path("cudart")),
+ "touch $(@D)/{}".format(cuda_library_path("cufft")),
+ "touch $(@D)/{}".format(cupti_library_path()),
+ ]),
),
local = 1,
)
@@ -191,7 +200,7 @@ genrule(
],
cmd = if_cuda(
# Under cuda config, create the symbolic link to the actual cuda.config
- "configfile=$(location :cuda.config); ln -sf `readlink -f $${configfile#*/*/*/}` $(@D)/;",
+ "configfile=$(location :cuda.config); ln -sf `{} -f $${{configfile#*/*/*/}}` $(@D)/;".format(readlink_command()),
# Under non-cuda config, create the dummy file
";".join([
diff --git a/third_party/gpus/cuda/cuda_config.sh b/third_party/gpus/cuda/cuda_config.sh
index e93a7ed741..0e1106bb70 100755
--- a/third_party/gpus/cuda/cuda_config.sh
+++ b/third_party/gpus/cuda/cuda_config.sh
@@ -54,7 +54,19 @@ source cuda.config || exit -1
OUTPUTDIR=${OUTPUTDIR:-../../..}
CUDA_TOOLKIT_PATH=${CUDA_TOOLKIT_PATH:-/usr/local/cuda}
-CUDNN_INSTALL_PATH=${CUDNN_INSTALL_PATH:-/usr/local/cuda}
+CUDNN_INSTALL_BASEDIR=${CUDNN_INSTALL_PATH:-/usr/local/cuda}
+
+if [[ -z "$TF_CUDA_VERSION" ]]; then
+ TF_CUDA_EXT=""
+else
+ TF_CUDA_EXT=".$TF_CUDA_VERSION"
+fi
+
+if [[ -z "$TF_CUDNN_VERSION" ]]; then
+ TF_CUDNN_EXT=""
+else
+ TF_CUDNN_EXT=".$TF_CUDNN_VERSION"
+fi
# An error message when the Cuda toolkit is not found
function CudaError {
@@ -99,59 +111,84 @@ function CheckAndLinkToSrcTree {
# Link the output file to the source tree, avoiding self links if they are
# the same. This could happen if invoked from the source tree by accident.
- if [ ! $(readlink -f $PWD) == $(readlink -f $OUTPUTDIR/third_party/gpus/cuda) ]; then
+ if [ ! $($READLINK_CMD -f $PWD) == $($READLINK_CMD -f $OUTPUTDIR/third_party/gpus/cuda) ]; then
mkdir -p $(dirname $OUTPUTDIR/third_party/gpus/cuda/$FILE)
ln -sf $PWD/$FILE $OUTPUTDIR/third_party/gpus/cuda/$FILE
fi
}
+OSNAME=`uname -s`
+if [ "$OSNAME" == "Linux" ]; then
+ CUDA_LIB_PATH="lib64"
+ CUDA_CUPTI_LIB_DIR="extras/CUPTI/lib64"
+ CUDA_RT_LIB_PATH="lib64/libcudart.so${TF_CUDA_EXT}"
+ CUDA_RT_LIB_STATIC_PATH="lib64/libcudart_static.a"
+ CUDA_BLAS_LIB_PATH="lib64/libcublas.so${TF_CUDA_EXT}"
+ CUDA_DNN_LIB_PATH="lib64/libcudnn.so${TF_CUDNN_EXT}"
+ CUDA_DNN_LIB_ALT_PATH="libcudnn.so${TF_CUDNN_EXT}"
+ CUDA_FFT_LIB_PATH="lib64/libcufft.so${TF_CUDA_EXT}"
+ CUDA_CUPTI_LIB_PATH="extras/CUPTI/lib64/libcupti.so${TF_CUDA_EXT}"
+ READLINK_CMD="readlink"
+elif [ "$OSNAME" == "Darwin" ]; then
+ CUDA_LIB_PATH="lib"
+ CUDA_CUPTI_LIB_DIR="extras/CUPTI/lib"
+ CUDA_RT_LIB_PATH="lib/libcudart${TF_CUDA_EXT}.dylib"
+ CUDA_RT_LIB_STATIC_PATH="lib/libcudart_static.a"
+ CUDA_BLAS_LIB_PATH="lib/libcublas${TF_CUDA_EXT}.dylib"
+ CUDA_DNN_LIB_PATH="lib/libcudnn${TF_CUDNN_EXT}.dylib"
+ CUDA_DNN_LIB_ALT_PATH="libcudnn${TF_CUDNN_EXT}.dylib"
+ CUDA_FFT_LIB_PATH="lib/libcufft${TF_CUDA_EXT}.dylib"
+ CUDA_CUPTI_LIB_PATH="extras/CUPTI/lib/libcupti${TF_CUDA_EXT}.dylib"
+ READLINK_CMD="greadlink"
+fi
+
if [ "$CHECK_ONLY" == "1" ]; then
CheckAndLinkToSrcTree CudaError include/cuda.h
CheckAndLinkToSrcTree CudaError include/cublas.h
CheckAndLinkToSrcTree CudnnError include/cudnn.h
CheckAndLinkToSrcTree CudaError extras/CUPTI/include/cupti.h
- CheckAndLinkToSrcTree CudaError lib64/libcudart_static.a
- CheckAndLinkToSrcTree CudaError lib64/libcublas.so$TF_CUDA_VERSION
- CheckAndLinkToSrcTree CudnnError lib64/libcudnn.so$TF_CUDNN_VERSION
- CheckAndLinkToSrcTree CudaError lib64/libcudart.so$TF_CUDA_VERSION
- CheckAndLinkToSrcTree CudaError lib64/libcufft.so$TF_CUDA_VERSION
- CheckAndLinkToSrcTree CudaError extras/CUPTI/lib64/libcupti.so$TF_CUDA_VERSION
+ CheckAndLinkToSrcTree CudaError $CUDA_RT_LIB_STATIC_PATH
+ CheckAndLinkToSrcTree CudaError $CUDA_BLAS_LIB_PATH
+ CheckAndLinkToSrcTree CudnnError $CUDA_DNN_LIB_PATH
+ CheckAndLinkToSrcTree CudaError $CUDA_RT_LIB_PATH
+ CheckAndLinkToSrcTree CudaError $CUDA_FFT_LIB_PATH
+ CheckAndLinkToSrcTree CudaError $CUDA_CUPTI_LIB_PATH
exit 0
fi
# Actually configure the source tree for TensorFlow's canonical view of Cuda
# libraries.
-if test ! -e ${CUDA_TOOLKIT_PATH}/lib64/libcudart.so$TF_CUDA_VERSION; then
- CudaError "cannot find ${CUDA_TOOLKIT_PATH}/lib64/libcudart.so$TF_CUDA_VERSION"
+if test ! -e ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}; then
+ CudaError "cannot find ${CUDA_TOOLKIT_PATH}/${CUDA_RT_LIB_PATH}"
fi
-if test ! -e ${CUDA_TOOLKIT_PATH}/extras/CUPTI/lib64/libcupti.so$TF_CUDA_VERSION; then
- CudaError "cannot find ${CUDA_TOOLKIT_PATH}/extras/CUPTI/lib64/libcupti.so$TF_CUDA_VERSION"
+if test ! -e ${CUDA_TOOLKIT_PATH}/${CUDA_CUPTI_LIB_PATH}; then
+ CudaError "cannot find ${CUDA_TOOLKIT_PATH}/${CUDA_CUPTI_LIB_PATH}"
fi
-if test ! -d ${CUDNN_INSTALL_PATH}; then
- CudnnError "cannot find dir: ${CUDNN_INSTALL_PATH}"
+if test ! -d ${CUDNN_INSTALL_BASEDIR}; then
+ CudnnError "cannot find dir: ${CUDNN_INSTALL_BASEDIR}"
fi
# Locate cudnn.h
-if test -e ${CUDNN_INSTALL_PATH}/cudnn.h; then
- CUDNN_HEADER_PATH=${CUDNN_INSTALL_PATH}
-elif test -e ${CUDNN_INSTALL_PATH}/include/cudnn.h; then
- CUDNN_HEADER_PATH=${CUDNN_INSTALL_PATH}/include
+if test -e ${CUDNN_INSTALL_BASEDIR}/cudnn.h; then
+ CUDNN_HEADER_DIR=${CUDNN_INSTALL_BASEDIR}
+elif test -e ${CUDNN_INSTALL_BASEDIR}/include/cudnn.h; then
+ CUDNN_HEADER_DIR=${CUDNN_INSTALL_BASEDIR}/include
elif test -e /usr/include/cudnn.h; then
- CUDNN_HEADER_PATH=/usr/include
+ CUDNN_HEADER_DIR=/usr/include
else
- CudnnError "cannot find cudnn.h under: ${CUDNN_INSTALL_PATH} or /usr/include"
+ CudnnError "cannot find cudnn.h under: ${CUDNN_INSTALL_BASEDIR}"
fi
-# Locate libcudnn.so.${$TF_CUDNN_VERSION}
-if test -e ${CUDNN_INSTALL_PATH}/libcudnn.so$TF_CUDNN_VERSION; then
- CUDNN_LIB_PATH=${CUDNN_INSTALL_PATH}
-elif test -e ${CUDNN_INSTALL_PATH}/lib64/libcudnn.so$TF_CUDNN_VERSION; then
- CUDNN_LIB_PATH=${CUDNN_INSTALL_PATH}/lib64
+# Locate libcudnn
+if test -e ${CUDNN_INSTALL_BASEDIR}/${CUDA_DNN_LIB_PATH}; then
+ CUDNN_LIB_INSTALL_PATH=${CUDNN_INSTALL_BASEDIR}/${CUDA_DNN_LIB_PATH}
+elif test -e ${CUDNN_INSTALL_BASEDIR}/${CUDA_DNN_LIB_ALT_PATH}; then
+ CUDNN_LIB_INSTALL_PATH=${CUDNN_INSTALL_BASEDIR}/${CUDA_DNN_LIB_ALT_PATH}
else
- CudnnError "cannot find libcudnn.so.$TF_CUDNN_VERSION under: ${CUDNN_INSTALL_PATH}"
+ CudnnError "cannot find ${CUDA_DNN_LIB_PATH} or ${CUDA_DNN_LIB_ALT_PATH} under: ${CUDNN_INSTALL_BASEDIR}"
fi
# Helper function to build symbolic links for all files under a directory.
@@ -181,8 +218,8 @@ function LinkAllFiles {
mkdir -p $OUTPUTDIR/third_party/gpus/cuda
echo "Setting up Cuda include"
LinkAllFiles ${CUDA_TOOLKIT_PATH}/include $OUTPUTDIR/third_party/gpus/cuda/include || exit -1
-echo "Setting up Cuda lib64"
-LinkAllFiles ${CUDA_TOOLKIT_PATH}/lib64 $OUTPUTDIR/third_party/gpus/cuda/lib64 || exit -1
+echo "Setting up Cuda ${CUDA_LIB_PATH}"
+LinkAllFiles ${CUDA_TOOLKIT_PATH}/${CUDA_LIB_PATH} $OUTPUTDIR/third_party/gpus/cuda/${CUDA_LIB_PATH} || exit -1
echo "Setting up Cuda bin"
LinkAllFiles ${CUDA_TOOLKIT_PATH}/bin $OUTPUTDIR/third_party/gpus/cuda/bin || exit -1
echo "Setting up Cuda nvvm"
@@ -190,8 +227,8 @@ LinkAllFiles ${CUDA_TOOLKIT_PATH}/nvvm $OUTPUTDIR/third_party/gpus/cuda/nvvm ||
echo "Setting up CUPTI include"
LinkAllFiles ${CUDA_TOOLKIT_PATH}/extras/CUPTI/include $OUTPUTDIR/third_party/gpus/cuda/extras/CUPTI/include || exit -1
echo "Setting up CUPTI lib64"
-LinkAllFiles ${CUDA_TOOLKIT_PATH}/extras/CUPTI/lib64 $OUTPUTDIR/third_party/gpus/cuda/extras/CUPTI/lib64 || exit -1
+LinkAllFiles ${CUDA_TOOLKIT_PATH}/${CUDA_CUPTI_LIB_DIR} $OUTPUTDIR/third_party/gpus/cuda/${CUDA_CUPTI_LIB_DIR} || exit -1
# Set up symbolic link for cudnn
-ln -sf $CUDNN_HEADER_PATH/cudnn.h $OUTPUTDIR/third_party/gpus/cuda/include/cudnn.h || exit -1
-ln -sf $CUDNN_LIB_PATH/libcudnn.so$TF_CUDNN_VERSION $OUTPUTDIR/third_party/gpus/cuda/lib64/libcudnn.so$TF_CUDNN_VERSION || exit -1
+ln -sf $CUDNN_HEADER_DIR/cudnn.h $OUTPUTDIR/third_party/gpus/cuda/include/cudnn.h || exit -1
+ln -sf $CUDNN_LIB_INSTALL_PATH $OUTPUTDIR/third_party/gpus/cuda/$CUDA_DNN_LIB_PATH || exit -1
diff --git a/third_party/gpus/cuda/platform.bzl b/third_party/gpus/cuda/platform.bzl
new file mode 100644
index 0000000000..20ab441bf4
--- /dev/null
+++ b/third_party/gpus/cuda/platform.bzl
@@ -0,0 +1,59 @@
+CUDA_VERSION = ""
+
+CUDNN_VERSION = ""
+
+PLATFORM = ""
+
+def cuda_sdk_version():
+ return CUDA_VERSION
+
+def cudnn_sdk_version():
+ return CUDNN_VERSION
+
+def cuda_library_path(name, version = cuda_sdk_version()):
+ if PLATFORM == "Darwin":
+ if not version:
+ return "lib/lib{}.dylib".format(name)
+ else:
+ return "lib/lib{}.{}.dylib".format(name, version)
+ else:
+ if not version:
+ return "lib64/lib{}.so".format(name)
+ else:
+ return "lib64/lib{}.so.{}".format(name, version)
+
+def cuda_static_library_path(name):
+ if PLATFORM == "Darwin":
+ return "lib/lib{}_static.a".format(name)
+ else:
+ return "lib64/lib{}_static.a".format(name)
+
+def cudnn_library_path(version = cudnn_sdk_version()):
+ if PLATFORM == "Darwin":
+ if not version:
+ return "lib/libcudnn.dylib"
+ else:
+ return "lib/libcudnn.{}.dylib".format(version)
+ else:
+ if not version:
+ return "lib64/libcudnn.so"
+ else:
+ return "lib64/libcudnn.so.{}".format(version)
+
+def cupti_library_path(version = cuda_sdk_version()):
+ if PLATFORM == "Darwin":
+ if not version:
+ return "extras/CUPTI/lib/libcupti.dylib"
+ else:
+ return "extras/CUPTI/lib/libcupti.{}.dylib".format(version)
+ else:
+ if not version:
+ return "extras/CUPTI/lib64/libcupti.so"
+ else:
+ return "extras/CUPTI/lib64/libcupti.so.{}".format(version)
+
+def readlink_command():
+ if PLATFORM == "Darwin":
+ return "greadlink"
+ else:
+ return "readlink"