1load(":build_defs.bzl", "cuda_header_library") 2load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 3load("@bazel_skylib//lib:selects.bzl", "selects") 4 5licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like 6 7package(default_visibility = ["//visibility:public"]) 8 9# Config setting whether TensorFlow is built with CUDA support using clang. 10# 11# TODO(b/174244321), DEPRECATED: this target will be removed when all users 12# have been converted to :is_cuda_enabled (most) or :is_cuda_compiler_clang. 13selects.config_setting_group( 14 name = "using_clang", 15 match_all = [ 16 "@local_config_cuda//:is_cuda_enabled", 17 "@local_config_cuda//:is_cuda_compiler_clang", 18 ], 19) 20 21# Config setting whether TensorFlow is built with CUDA support using nvcc. 22# 23# TODO(b/174244321), DEPRECATED: this target will be removed when all users 24# have been converted to :is_cuda_enabled (most) or :is_cuda_compiler_nvcc. 25selects.config_setting_group( 26 name = "using_nvcc", 27 match_all = [ 28 "@local_config_cuda//:is_cuda_enabled", 29 "@local_config_cuda//:is_cuda_compiler_nvcc", 30 ], 31) 32 33# Equivalent to using_clang && -c opt. 34selects.config_setting_group( 35 name = "using_clang_opt", 36 match_all = [ 37 ":using_clang", 38 ":_opt", 39 ], 40) 41 42config_setting( 43 name = "_opt", 44 values = {"compilation_mode": "opt"}, 45 visibility = ["//visibility:private"], 46) 47 48# Provides CUDA headers for '#include "third_party/gpus/cuda/include/cuda.h"' 49# All clients including TensorFlow should use these directives. 50cuda_header_library( 51 name = "cuda_headers", 52 hdrs = [ 53 "cuda/cuda_config.h", 54 ":cuda-include", 55 ], 56 include_prefix = "third_party/gpus", 57 includes = [ 58 ".", # required to include cuda/cuda/cuda_config.h as cuda/config.h 59 "cuda/include", 60 ], 61) 62 63cc_library( 64 name = "cudart_static", 65 srcs = ["cuda/lib/%{cudart_static_lib}"], 66 linkopts = [ 67 "-ldl", 68 "-lpthread", 69 %{cudart_static_linkopt} 70 ], 71) 72 73cc_library( 74 name = "cuda_driver", 75 srcs = ["cuda/lib/%{cuda_driver_lib}"], 76) 77 78cc_library( 79 name = "cudart", 80 srcs = ["cuda/lib/%{cudart_lib}"], 81 data = ["cuda/lib/%{cudart_lib}"], 82 linkstatic = 1, 83) 84 85cuda_header_library( 86 name = "cublas_headers", 87 hdrs = [":cublas-include"], 88 include_prefix = "third_party/gpus/cuda/include", 89 includes = ["cublas/include"], 90 strip_include_prefix = "cublas/include", 91 deps = [":cuda_headers"], 92) 93 94cuda_header_library( 95 name = "cusolver_headers", 96 hdrs = [":cusolver-include"], 97 include_prefix = "third_party/gpus/cuda/include", 98 includes = ["cusolver/include"], 99 strip_include_prefix = "cusolver/include", 100 deps = [":cuda_headers"], 101) 102 103cuda_header_library( 104 name = "cufft_headers", 105 hdrs = [":cufft-include"], 106 include_prefix = "third_party/gpus/cuda/include", 107 includes = ["cufft/include"], 108 strip_include_prefix = "cufft/include", 109 deps = [":cuda_headers"], 110) 111 112cuda_header_library( 113 name = "cusparse_headers", 114 hdrs = [":cusparse-include"], 115 include_prefix = "third_party/gpus/cuda/include", 116 includes = ["cusparse/include"], 117 strip_include_prefix = "cusparse/include", 118 deps = [":cuda_headers"], 119) 120 121cuda_header_library( 122 name = "curand_headers", 123 hdrs = [":curand-include"], 124 include_prefix = "third_party/gpus/cuda/include", 125 includes = ["curand/include"], 126 strip_include_prefix = "curand/include", 127 deps = [":cuda_headers"], 128) 129 130cc_library( 131 name = "cublas", 132 srcs = ["cuda/lib/%{cublas_lib}"], 133 data = ["cuda/lib/%{cublas_lib}"], 134 linkstatic = 1, 135) 136 137cc_library( 138 name = "cublasLt", 139 srcs = ["cuda/lib/%{cublasLt_lib}"], 140 data = ["cuda/lib/%{cublasLt_lib}"], 141 linkstatic = 1, 142) 143 144cc_library( 145 name = "cusolver", 146 srcs = ["cuda/lib/%{cusolver_lib}"], 147 data = ["cuda/lib/%{cusolver_lib}"], 148 linkopts = ["-lgomp"], 149 linkstatic = 1, 150) 151 152cc_library( 153 name = "cudnn", 154 srcs = ["cuda/lib/%{cudnn_lib}"], 155 data = ["cuda/lib/%{cudnn_lib}"], 156 linkstatic = 1, 157) 158 159cc_library( 160 name = "cudnn_header", 161 hdrs = [":cudnn-include"], 162 include_prefix = "third_party/gpus/cudnn", 163 strip_include_prefix = "cudnn/include", 164 deps = [":cuda_headers"], 165) 166 167cc_library( 168 name = "cufft", 169 srcs = ["cuda/lib/%{cufft_lib}"], 170 data = ["cuda/lib/%{cufft_lib}"], 171 linkstatic = 1, 172) 173 174cc_library( 175 name = "curand", 176 srcs = ["cuda/lib/%{curand_lib}"], 177 data = ["cuda/lib/%{curand_lib}"], 178 linkstatic = 1, 179) 180 181cc_library( 182 name = "cuda", 183 deps = [ 184 ":cublas", 185 ":cublasLt", 186 ":cuda_headers", 187 ":cudart", 188 ":cudnn", 189 ":cufft", 190 ":curand", 191 ], 192) 193 194alias( 195 name = "cub_headers", 196 actual = "%{cub_actual}", 197) 198 199cuda_header_library( 200 name = "cupti_headers", 201 hdrs = [":cuda-extras"], 202 include_prefix = "third_party/gpus", 203 includes = ["cuda/extras/CUPTI/include/"], 204 deps = [":cuda_headers"], 205) 206 207cc_library( 208 name = "cupti_dsos", 209 data = ["cuda/lib/%{cupti_lib}"], 210) 211 212cc_library( 213 name = "cusparse", 214 srcs = ["cuda/lib/%{cusparse_lib}"], 215 data = ["cuda/lib/%{cusparse_lib}"], 216 linkopts = ["-lgomp"], 217 linkstatic = 1, 218) 219 220cc_library( 221 name = "libdevice_root", 222 data = [":cuda-nvvm"], 223) 224 225bzl_library( 226 name = "build_defs_bzl", 227 srcs = ["build_defs.bzl"], 228 deps = [ 229 "@bazel_skylib//lib:selects", 230 ], 231) 232 233py_library( 234 name = "cuda_config_py", 235 srcs = ["cuda/cuda_config.py"], 236) 237 238%{copy_rules} 239