This change reimplements the CUDA autoconfiguration mechanism in Skylark, providing a `cuda_configure` workspace rule. We keep the same user interface, the ./configure script, but rather than modifying source files within the source tree, `cuda_configure` generates a `@local_config_cuda` workspace containing: * Symlinks to the CUDA headers and libraries * BUILD files generated with the correct CUDA and cuDNN versions * CROSSTOOL config with CUDA include dirs populated * crosstool_wrapper_driver_is_not_gcc wrapper script with compiler paths and CUDA compute capabilities set. * cuda_config.h header file with CUDA versions and compute capabilities set, which can be `#include`d by source files. This change also makes the following fixes to `Dockerfile.gpu`: * Change the `CUDNN_INSTALL_PATH` to point to `/usr/lib/x86_64-linux-gnu` rather than `/usr/local/cuda` since NVIDIA's image installs `libcudnn.so` under `/usr/lib/x86_64-linux-gnu`. * Add env variable to set the minimum compute capability to 3.0. Fixes #2873
173 lines
3.3 KiB
Smarty
173 lines
3.3 KiB
Smarty
licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like
|
|
|
|
load("@local_config_cuda//cuda:platform.bzl", "cuda_library_path")
|
|
load("@local_config_cuda//cuda:platform.bzl", "cuda_static_library_path")
|
|
load("@local_config_cuda//cuda:platform.bzl", "cudnn_library_path")
|
|
load("@local_config_cuda//cuda:platform.bzl", "cupti_library_path")
|
|
load("@local_config_cuda//cuda:platform.bzl", "readlink_command")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
config_setting(
|
|
name = "using_gcudacc",
|
|
values = {
|
|
"define": "using_cuda_gcudacc=true",
|
|
},
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
config_setting(
|
|
name = "using_nvcc",
|
|
values = {
|
|
"define": "using_cuda_nvcc=true",
|
|
},
|
|
)
|
|
|
|
config_setting(
|
|
name = "using_clang",
|
|
values = {
|
|
"define": "using_cuda_clang=true",
|
|
},
|
|
)
|
|
|
|
# Equivalent to using_clang && -c opt.
|
|
config_setting(
|
|
name = "using_clang_opt",
|
|
values = {
|
|
"define": "using_cuda_clang=true",
|
|
"compilation_mode": "opt",
|
|
},
|
|
)
|
|
|
|
config_setting(
|
|
name = "darwin",
|
|
values = {"cpu": "darwin"},
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cuda_headers",
|
|
hdrs = glob([
|
|
"**/*.h",
|
|
]),
|
|
includes = [
|
|
".",
|
|
"include",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cudart_static",
|
|
srcs = [
|
|
cuda_static_library_path("cudart"),
|
|
],
|
|
includes = ["include/"],
|
|
linkopts = [
|
|
"-ldl",
|
|
"-lpthread",
|
|
] + select({
|
|
"@//tensorflow:darwin": [],
|
|
"//conditions:default": ["-lrt"],
|
|
}),
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cudart",
|
|
srcs = [
|
|
cuda_library_path("cudart"),
|
|
],
|
|
data = [
|
|
cuda_library_path("cudart"),
|
|
],
|
|
includes = ["include/"],
|
|
linkstatic = 1,
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cublas",
|
|
srcs = [
|
|
cuda_library_path("cublas"),
|
|
],
|
|
data = [
|
|
cuda_library_path("cublas"),
|
|
],
|
|
includes = ["include/"],
|
|
linkstatic = 1,
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cudnn",
|
|
srcs = [
|
|
cudnn_library_path(),
|
|
],
|
|
data = [
|
|
cudnn_library_path(),
|
|
],
|
|
includes = ["include/"],
|
|
linkstatic = 1,
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cufft",
|
|
srcs = [
|
|
cuda_library_path("cufft"),
|
|
],
|
|
data = [
|
|
cuda_library_path("cufft"),
|
|
],
|
|
includes = ["include/"],
|
|
linkstatic = 1,
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "curand",
|
|
srcs = [
|
|
cuda_library_path("curand"),
|
|
],
|
|
data = [
|
|
cuda_library_path("curand"),
|
|
],
|
|
includes = ["include/"],
|
|
linkstatic = 1,
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cuda",
|
|
deps = [
|
|
":cuda_headers",
|
|
":cudart",
|
|
":cublas",
|
|
":cudnn",
|
|
":cufft",
|
|
":curand",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cupti_headers",
|
|
hdrs = glob([
|
|
"**/*.h",
|
|
]),
|
|
includes = [
|
|
".",
|
|
"extras/CUPTI/include/",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "cupti_dsos",
|
|
data = [
|
|
cupti_library_path(),
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
)
|