1load(":build_defs.bzl", "cuda_header_library") 2load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 3 4licenses(["restricted"]) # MPL2, portions GPL v3, LGPL v3, BSD-like 5 6package(default_visibility = ["//visibility:public"]) 7 8config_setting( 9 name = "using_nvcc", 10 values = { 11 "define": "using_cuda_nvcc=true", 12 }, 13) 14 15config_setting( 16 name = "using_clang", 17 values = { 18 "define": "using_cuda_clang=true", 19 }, 20) 21 22# Equivalent to using_clang && -c opt. 23config_setting( 24 name = "using_clang_opt", 25 values = { 26 "define": "using_cuda_clang=true", 27 "compilation_mode": "opt", 28 }, 29) 30 31config_setting( 32 name = "darwin", 33 values = {"cpu": "darwin"}, 34) 35 36config_setting( 37 name = "freebsd", 38 values = {"cpu": "freebsd"}, 39) 40 41# Provides CUDA headers for '#include "third_party/gpus/cuda/include/cuda.h"' 42# All clients including TensorFlow should use these directives. 43cuda_header_library( 44 name = "cuda_headers", 45 hdrs = [ 46 "cuda/cuda_config.h", 47 ":cuda-include" 48 ], 49 include_prefix = "third_party/gpus", 50 includes = [ 51 ".", # required to include cuda/cuda/cuda_config.h as cuda/config.h 52 "cuda/include", 53 ], 54) 55 56cc_import( 57 name = "cudart_static", 58 # /WHOLEARCHIVE:cudart_static.lib will cause a 59 # "Internal error during CImplib::EmitThunk" error. 60 # Treat this library as interface library to avoid being whole archived when 61 # linking a DLL that depends on this. 62 # TODO(pcloudy): Remove this rule after b/111278841 is resolved. 63 interface_library = "cuda/lib/%{cudart_static_lib}", 64 system_provided = 1, 65) 66 67cc_import( 68 name = "cuda_driver", 69 interface_library = "cuda/lib/%{cuda_driver_lib}", 70 system_provided = 1, 71) 72 73cc_import( 74 name = "cudart", 75 interface_library = "cuda/lib/%{cudart_lib}", 76 system_provided = 1, 77) 78 79cuda_header_library( 80 name = "cublas_headers", 81 hdrs = [":cublas-include"], 82 include_prefix = "third_party/gpus/cuda/include", 83 includes = ["cublas/include"], 84 strip_include_prefix = "cublas/include", 85 deps = [":cuda_headers"], 86) 87 88cc_import( 89 name = "cublas", 90 interface_library = "cuda/lib/%{cublas_lib}", 91 system_provided = 1, 92) 93 94cc_import( 95 name = "cusolver", 96 interface_library = "cuda/lib/%{cusolver_lib}", 97 system_provided = 1, 98) 99 100cc_import( 101 name = "cudnn", 102 interface_library = "cuda/lib/%{cudnn_lib}", 103 system_provided = 1, 104) 105 106cc_library( 107 name = "cudnn_header", 108 hdrs = [":cudnn-include"], 109 include_prefix = "third_party/gpus/cudnn", 110 strip_include_prefix = "cudnn/include", 111 deps = [":cuda_headers"], 112) 113 114cc_import( 115 name = "cufft", 116 interface_library = "cuda/lib/%{cufft_lib}", 117 system_provided = 1, 118) 119 120cc_import( 121 name = "curand", 122 interface_library = "cuda/lib/%{curand_lib}", 123 system_provided = 1, 124) 125 126cc_library( 127 name = "cuda", 128 deps = [ 129 ":cublas", 130 ":cuda_headers", 131 ":cudart", 132 ":cudnn", 133 ":cufft", 134 ":curand", 135 ], 136) 137 138cuda_header_library( 139 name = "cupti_headers", 140 hdrs = [":cuda-extras"], 141 include_prefix="third_party/gpus", 142 includes = ["cuda/extras/CUPTI/include/"], 143 deps = [":cuda_headers"], 144) 145 146cc_import( 147 name = "cupti_dsos", 148 interface_library = "cuda/lib/%{cupti_lib}", 149 system_provided = 1, 150) 151 152cc_import( 153 name = "cusparse", 154 interface_library = "cuda/lib/%{cusparse_lib}", 155 system_provided = 1, 156) 157 158cc_library( 159 name = "libdevice_root", 160 data = [":cuda-nvvm"], 161) 162 163bzl_library( 164 name = "build_defs_bzl", 165 srcs = ["build_defs.bzl"], 166 deps = [ 167 "@bazel_skylib//lib:selects", 168 ], 169) 170 171%{copy_rules} 172