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_import( 64 name = "cudart_static", 65 # /WHOLEARCHIVE:cudart_static.lib will cause a 66 # "Internal error during CImplib::EmitThunk" error. 67 # Treat this library as interface library to avoid being whole archived when 68 # linking a DLL that depends on this. 69 # TODO(pcloudy): Remove this rule after b/111278841 is resolved. 70 interface_library = "cuda/lib/%{cudart_static_lib}", 71 system_provided = 1, 72) 73 74cc_import( 75 name = "cuda_driver", 76 interface_library = "cuda/lib/%{cuda_driver_lib}", 77 system_provided = 1, 78) 79 80cc_import( 81 name = "cudart", 82 interface_library = "cuda/lib/%{cudart_lib}", 83 system_provided = 1, 84) 85 86cuda_header_library( 87 name = "cublas_headers", 88 hdrs = [":cublas-include"], 89 include_prefix = "third_party/gpus/cuda/include", 90 includes = ["cublas/include"], 91 strip_include_prefix = "cublas/include", 92 deps = [":cuda_headers"], 93) 94 95cuda_header_library( 96 name = "cusolver_headers", 97 hdrs = [":cusolver-include"], 98 include_prefix = "third_party/gpus/cuda/include", 99 includes = ["cusolver/include"], 100 strip_include_prefix = "cusolver/include", 101 deps = [":cuda_headers"], 102) 103 104cuda_header_library( 105 name = "cufft_headers", 106 hdrs = [":cufft-include"], 107 include_prefix = "third_party/gpus/cuda/include", 108 includes = ["cufft/include"], 109 strip_include_prefix = "cufft/include", 110 deps = [":cuda_headers"], 111) 112 113cuda_header_library( 114 name = "cusparse_headers", 115 hdrs = [":cusparse-include"], 116 include_prefix = "third_party/gpus/cuda/include", 117 includes = ["cusparse/include"], 118 strip_include_prefix = "cusparse/include", 119 deps = [":cuda_headers"], 120) 121 122cuda_header_library( 123 name = "curand_headers", 124 hdrs = [":curand-include"], 125 include_prefix = "third_party/gpus/cuda/include", 126 includes = ["curand/include"], 127 strip_include_prefix = "curand/include", 128 deps = [":cuda_headers"], 129) 130 131cc_import( 132 name = "cublas", 133 interface_library = "cuda/lib/%{cublas_lib}", 134 system_provided = 1, 135) 136 137cc_import( 138 name = "cublasLt", 139 interface_library = "cuda/lib/%{cublasLt_lib}", 140 system_provided = 1, 141) 142 143cc_import( 144 name = "cusolver", 145 interface_library = "cuda/lib/%{cusolver_lib}", 146 system_provided = 1, 147) 148 149cc_import( 150 name = "cudnn", 151 interface_library = "cuda/lib/%{cudnn_lib}", 152 system_provided = 1, 153) 154 155cc_library( 156 name = "cudnn_header", 157 hdrs = [":cudnn-include"], 158 include_prefix = "third_party/gpus/cudnn", 159 strip_include_prefix = "cudnn/include", 160 deps = [":cuda_headers"], 161) 162 163cc_import( 164 name = "cufft", 165 interface_library = "cuda/lib/%{cufft_lib}", 166 system_provided = 1, 167) 168 169cc_import( 170 name = "curand", 171 interface_library = "cuda/lib/%{curand_lib}", 172 system_provided = 1, 173) 174 175cc_library( 176 name = "cuda", 177 deps = [ 178 ":cublas", 179 ":cublasLt", 180 ":cuda_headers", 181 ":cudart", 182 ":cudnn", 183 ":cufft", 184 ":curand", 185 ], 186) 187 188alias( 189 name = "cub_headers", 190 actual = "%{cub_actual}", 191) 192 193cuda_header_library( 194 name = "cupti_headers", 195 hdrs = [":cuda-extras"], 196 include_prefix = "third_party/gpus", 197 includes = ["cuda/extras/CUPTI/include/"], 198 deps = [":cuda_headers"], 199) 200 201cc_import( 202 name = "cupti_dsos", 203 interface_library = "cuda/lib/%{cupti_lib}", 204 system_provided = 1, 205) 206 207cc_import( 208 name = "cusparse", 209 interface_library = "cuda/lib/%{cusparse_lib}", 210 system_provided = 1, 211) 212 213cc_library( 214 name = "libdevice_root", 215 data = [":cuda-nvvm"], 216) 217 218bzl_library( 219 name = "build_defs_bzl", 220 srcs = ["build_defs.bzl"], 221 deps = [ 222 "@bazel_skylib//lib:selects", 223 ], 224) 225 226py_library( 227 name = "cuda_config_py", 228 srcs = ["cuda/cuda_config.py"], 229) 230 231%{copy_rules} 232