-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathBUILD.tpl
More file actions
352 lines (296 loc) · 6.92 KB
/
Copy pathBUILD.tpl
File metadata and controls
352 lines (296 loc) · 6.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@cuda_cudart//:version.bzl", _cudart_version = "VERSION")
licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like
package(default_visibility = ["//visibility:public"])
# Config setting whether TensorFlow is built with CUDA support using clang.
#
# TODO(b/174244321), DEPRECATED: this target will be removed when all users
# have been converted to :is_cuda_enabled (most) or :is_cuda_compiler_clang.
selects.config_setting_group(
name = "using_clang",
match_all = [
"@local_config_cuda//:is_cuda_enabled",
"@local_config_cuda//:is_cuda_compiler_clang",
],
)
# Config setting whether TensorFlow is built with CUDA support using nvcc.
#
# TODO(b/174244321), DEPRECATED: this target will be removed when all users
# have been converted to :is_cuda_enabled (most) or :is_cuda_compiler_nvcc.
selects.config_setting_group(
name = "using_nvcc",
match_all = [
"@local_config_cuda//:is_cuda_enabled",
"@local_config_cuda//:is_cuda_compiler_nvcc",
],
)
# Equivalent to using_clang && -c opt.
selects.config_setting_group(
name = "using_clang_opt",
match_all = [
":using_clang",
":_opt",
],
)
config_setting(
name = "_opt",
values = {"compilation_mode": "opt"},
)
# Provides CUDA headers for '#include "third_party/gpus/cuda/include/cuda.h"'
# All clients including TensorFlow should use these directives.
cc_library(
name = "cuda_headers",
hdrs = [
"cuda/cuda_config.h",
],
include_prefix = "third_party/gpus",
includes = [
".", # required to include cuda/cuda/cuda_config.h as cuda/config.h
],
deps = [":cudart_headers",
":cublas_headers",
":profiler_api_headers",
":cccl_headers",
":nvtx_headers",
":nvcc_headers",
":cusolver_headers",
":cufft_headers",
":cusparse_headers",
":curand_headers",
":cupti_headers",
":nvml_headers",
":nvjitlink_headers",
] + ([":crt_headers"] if _cudart_version and int(_cudart_version)>=13 else []),
)
# This target is needed by the `cuda_library` rule. We can't implicitly
# depend on `:cuda_headers` directly since the user may explicit depend
# on `:cuda_headers` and duplicated dependencies are not allowed in Bazel.
# There is also no good way to deduplicate dependencies, but an alias works
# just fine.
alias(
name = "implicit_cuda_headers_dependency",
actual = ":cuda_headers",
)
cc_library(
name = "cudart_static",
srcs = ["@cuda_cudart//:static"],
linkopts = [
"-ldl",
"-lpthread",
%{cudart_static_linkopt}
],
)
alias(
name = "cuda_runtime",
actual = ":cudart_static",
)
alias(
name = "cuda_driver",
actual = select({
"@cuda_driver//:forward_compatibility": "@cuda_driver//:nvidia_driver",
"//conditions:default": "@cuda_cudart//:cuda_driver",
}),
)
alias(
name = "cudart_headers",
actual = "@cuda_cudart//:headers",
)
alias(
name = "cudart",
actual = "@cuda_cudart//:cudart",
)
alias(
name = "nvtx_headers",
actual = "@cuda_nvtx//:headers",
)
alias(
name = "nvml_headers",
actual = "@cuda_nvml//:headers",
)
alias(
name = "nvcc_headers",
actual = "@cuda_nvcc//:headers",
)
alias(
name = "crt_headers",
actual = "@cuda_crt//:headers",
)
alias(
name = "cccl_headers",
actual = "@cuda_cccl//:headers",
)
alias(
name = "cublas_headers",
actual = "@cuda_cublas//:headers",
)
alias(
name = "profiler_api_headers",
actual = "@cuda_profiler_api//:headers",
)
alias(
name = "cusolver_headers",
actual = "@cuda_cusolver//:headers",
)
alias(
name = "cufft_headers",
actual = "@cuda_cufft//:headers",
)
alias(
name = "cusparse_headers",
actual = "@cuda_cusparse//:headers",
)
alias(
name = "curand_headers",
actual = "@cuda_curand//:headers",
)
alias(
name = "nvjitlink_headers",
actual = "@cuda_nvjitlink//:headers",
)
alias(
name = "nvrtc_headers",
actual = "@cuda_nvrtc//:headers",
)
alias(
name = "cublas",
actual = "@cuda_cublas//:cublas",
)
alias(
name = "cublasLt",
actual = "@cuda_cublas//:cublasLt",
)
alias(
name = "cusolver",
actual = "@cuda_cusolver//:cusolver",
)
alias(
name = "cudnn",
actual = "@cuda_cudnn//:cudnn",
)
alias(
name = "cudnn_header",
actual = "@cuda_cudnn//:headers",
)
alias(
name = "cufft",
actual = "@cuda_cufft//:cufft",
)
alias(
name = "curand",
actual = "@cuda_curand//:curand",
)
alias(
name = "nvrtc",
actual = "@cuda_nvrtc//:nvrtc",
)
cc_library(
name = "cuda",
deps = [
":cublas",
":cublasLt",
":cuda_headers",
":cudart",
":cudnn",
":cufft",
":curand",
],
)
alias(
name = "cub_headers",
actual = ":cuda_headers",
)
alias(
name = "cupti_headers",
actual = "@cuda_cupti//:headers",
)
alias(
name = "cupti_dsos",
actual = "@cuda_cupti//:cupti",
)
alias(
name = "cusparse",
actual = "@cuda_cusparse//:cusparse",
)
alias(
name = "cuda-nvvm",
actual = "@cuda_nvcc//:nvvm" if _cudart_version and int(_cudart_version) < 13 else "@cuda_nvvm//:nvvm",
)
alias(
name = "nvjitlink",
actual = "@cuda_nvjitlink//:nvjitlink"
)
cc_library(
name = "libdevice_root",
data = [":cuda-nvvm"],
)
bzl_library(
name = "build_defs_bzl",
srcs = ["build_defs.bzl"],
deps = [
"@bazel_skylib//lib:selects",
],
)
py_library(
name = "cuda_config_py",
srcs = ["cuda/cuda_config.py"],
)
# Config setting whether TensorFlow is built with CUDA.
alias(
name = "cuda_tools",
actual = "@local_config_cuda//:is_cuda_enabled",
)
# Flag indicating if we should include CUDA libs.
bool_flag(
name = "include_cuda_libs",
build_setting_default = False,
)
config_setting(
name = "cuda_libs",
flag_values = {":include_cuda_libs": "True"},
)
# This flag should be used only when someone wants to build the wheel with CUDA
# dependencies.
bool_flag(
name = "override_include_cuda_libs",
build_setting_default = False,
)
config_setting(
name = "overrided_cuda_libs",
flag_values = {":override_include_cuda_libs": "True"},
)
selects.config_setting_group(
name = "any_cuda_libs",
match_any = [
":cuda_libs",
":overrided_cuda_libs"
],
)
selects.config_setting_group(
name = "cuda_tools_and_libs",
match_all = [
":any_cuda_libs",
":cuda_tools"
],
)
alias(
name = "nvptxcompiler",
actual = "@cuda_nvcc//:nvptxcompiler",
)
alias(
name = "runtime_fatbinary",
actual = "@cuda_nvcc//:fatbinary",
)
alias(
name = "runtime_nvlink",
actual = "@cuda_nvcc//:nvlink",
)
alias(
name = "runtime_ptxas",
actual = "@cuda_nvcc//:ptxas",
)
alias(
name = "runtime_nvdisasm",
actual = "@cuda_nvdisasm//:nvdisasm",
)