diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cublas.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cublas.BUILD.tpl index 510235d801de4e..dae6d80588122f 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cublas.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cublas.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -21,12 +25,14 @@ cc_library( name = "cublas", visibility = ["//visibility:public"], %{comment}deps = [":cublas_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/cublas/lib"), ) cc_library( name = "cublasLt", visibility = ["//visibility:public"], %{comment}deps = [":cublasLt_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/cublas/lib"), ) cc_library( diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudart.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudart.BUILD.tpl index 04d2de148c78c0..43ecfae61b9bd8 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudart.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudart.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -36,6 +40,7 @@ cc_library( %{comment}}) + [ %{comment}":cudart_shared_library", %{comment}], + %{comment}linkopts = cuda_rpath_flags("nvidia/cuda_runtime/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn.BUILD.tpl index 165c5b1579e73f..8fd8221afa6627 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -58,6 +62,7 @@ cc_library( %{comment}"@cuda_nvrtc//:nvrtc", %{comment}":cudnn_main", %{comment}], + %{comment}linkopts = cuda_rpath_flags("nvidia/cudnn/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn9.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn9.BUILD.tpl index 7f36054a51bb5b..feae35ea3b64c6 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn9.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cudnn9.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -65,6 +69,7 @@ cc_library( %{comment}"@cuda_nvrtc//:nvrtc", %{comment}":cudnn_main", %{comment}], + %{comment}linkopts = cuda_rpath_flags("nvidia/cudnn/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cufft.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cufft.BUILD.tpl index 48ccb0ea3cd197..9264d2f04af792 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cufft.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cufft.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -13,6 +17,7 @@ cc_import( cc_library( name = "cufft", %{comment}deps = [":cufft_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/cufft/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cupti.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cupti.BUILD.tpl index 3991b486195bc5..539b24df708a8d 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cupti.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cupti.BUILD.tpl @@ -1,5 +1,10 @@ licenses(["restricted"]) # NVIDIA proprietary license load("@local_config_cuda//cuda:build_defs.bzl", "if_version_equal_or_greater_than") +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) + exports_files([ "version.txt", ]) @@ -13,6 +18,7 @@ cc_import( cc_library( name = "cupti", %{comment}deps = [":cupti_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/cuda_cupti/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_curand.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_curand.BUILD.tpl index 50e5a8f18a96fd..f1b4be1f973eca 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_curand.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_curand.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -13,6 +17,7 @@ cc_import( cc_library( name = "curand", %{comment}deps = [":curand_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/curand/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusolver.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusolver.BUILD.tpl index 943a08ebeb96e1..8adf12d8415879 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusolver.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusolver.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -19,6 +23,7 @@ cc_import( cc_library( name = "cusolver", %{comment}deps = [":cusolver_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/cusolver/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusparse.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusparse.BUILD.tpl index 46b24366ce1c04..7884cb9029a45e 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusparse.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_cusparse.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -14,6 +18,7 @@ cc_import( cc_library( name = "cusparse", %{comment}deps = [":cusparse_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/cusparse/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvjitlink.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvjitlink.BUILD.tpl index 0494008e7924f3..feb2feb8f6647c 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvjitlink.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvjitlink.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -13,6 +17,7 @@ cc_import( cc_library( name = "nvjitlink", %{comment}deps = [":nvjitlink_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/nvjitlink/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvrtc.BUILD.tpl b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvrtc.BUILD.tpl index de18489b455b79..7c0399a72e7d54 100644 --- a/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvrtc.BUILD.tpl +++ b/third_party/tsl/third_party/gpus/cuda/hermetic/cuda_nvrtc.BUILD.tpl @@ -1,4 +1,9 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) + %{multiline_comment} cc_import( name = "nvrtc_main", @@ -16,5 +21,6 @@ cc_library( %{comment}":nvrtc_main", %{comment}":nvrtc_builtins", %{comment}], + %{comment}linkopts = cuda_rpath_flags("nvidia/cuda_nvrtc/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/nccl/hermetic/cuda_nccl.BUILD.tpl b/third_party/tsl/third_party/nccl/hermetic/cuda_nccl.BUILD.tpl index 61d7809bcdaad1..8dcd78f7bb8623 100644 --- a/third_party/tsl/third_party/nccl/hermetic/cuda_nccl.BUILD.tpl +++ b/third_party/tsl/third_party/nccl/hermetic/cuda_nccl.BUILD.tpl @@ -1,4 +1,8 @@ licenses(["restricted"]) # NVIDIA proprietary license +load( + "@xla//xla/tsl/platform/default:cuda_build_defs.bzl", + "cuda_rpath_flags", +) exports_files([ "version.txt", @@ -14,6 +18,7 @@ cc_import( cc_library( name = "nccl", %{comment}deps = [":nccl_shared_library"], + %{comment}linkopts = cuda_rpath_flags("nvidia/nccl/lib"), visibility = ["//visibility:public"], ) diff --git a/third_party/tsl/third_party/py/py_import.bzl b/third_party/tsl/third_party/py/py_import.bzl index b00ca49418423d..3a371c2ebfe500 100644 --- a/third_party/tsl/third_party/py/py_import.bzl +++ b/third_party/tsl/third_party/py/py_import.bzl @@ -2,13 +2,6 @@ def _unpacked_wheel_impl(ctx): output_dir = ctx.actions.declare_directory(ctx.label.name) - libs = [] - for dep in ctx.attr.cc_deps: - linker_inputs = dep[CcInfo].linking_context.linker_inputs.to_list() - for linker_input in linker_inputs: - if linker_input.libraries and linker_input.libraries[0].dynamic_library: - lib = linker_input.libraries[0].dynamic_library - libs.append(lib) wheel = None for w in ctx.files.wheel_rule_outputs: if w.basename.endswith(".whl"): @@ -16,17 +9,20 @@ def _unpacked_wheel_impl(ctx): break script = """ {zipper} x {wheel} -d {output} - for lib in {libs}; do - cp $lib {output}/tensorflow + for wheel_dep in {wheel_deps}; do + {zipper} x $wheel_dep -d {output} done """.format( zipper = ctx.executable.zipper.path, wheel = wheel.path, output = output_dir.path, - libs = " ".join(["'%s'" % lib.path for lib in libs]), + wheel_deps = " ".join([ + "'%s'" % wheel_dep.path + for wheel_dep in ctx.files.wheel_deps + ]), ) ctx.actions.run_shell( - inputs = ctx.files.wheel_rule_outputs + libs, + inputs = ctx.files.wheel_rule_outputs + ctx.files.wheel_deps, command = script, outputs = [output_dir], tools = [ctx.executable.zipper], @@ -45,16 +41,20 @@ _unpacked_wheel = rule( cfg = "exec", executable = True, ), - "cc_deps": attr.label_list(providers = [CcInfo]), + "wheel_deps": attr.label_list(allow_files = True), }, ) -def py_import(name, wheel, deps = [], cc_deps = []): +def py_import( + name, + wheel, + deps = [], + wheel_deps = []): unpacked_wheel_name = name + "_unpacked_wheel" _unpacked_wheel( name = unpacked_wheel_name, wheel_rule_outputs = wheel, - cc_deps = cc_deps, + wheel_deps = wheel_deps, ) native.py_library( name = name, @@ -68,6 +68,6 @@ def py_import(name, wheel, deps = [], cc_deps = []): Args: wheel: wheel file to unpack. deps: dependencies of the py_library. - cc_deps: dependencies that will be copied in the folder - with the unpacked wheel content. + wheel_deps: additional wheels to unpack. These wheels will be unpacked in the + same folder as the wheel. """ # buildifier: disable=no-effect