2023-01-02 14:28:25 +00:00
|
|
|
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
|
2025-03-26 11:18:29 +00:00
|
|
|
load("@zml//bazel:patchelf.bzl", "patchelf")
|
2023-01-02 14:28:25 +00:00
|
|
|
|
2025-03-26 11:18:29 +00:00
|
|
|
patchelf(
|
2025-07-08 09:25:25 +00:00
|
|
|
name = "libpjrt_cuda_so",
|
2025-07-07 16:48:07 +00:00
|
|
|
src = "libpjrt_cuda.so",
|
2025-03-26 11:18:29 +00:00
|
|
|
add_needed = [
|
|
|
|
|
"libzmlxcuda.so.0",
|
|
|
|
|
],
|
|
|
|
|
rename_dynamic_symbols = {
|
|
|
|
|
"dlopen": "zmlxcuda_dlopen",
|
|
|
|
|
},
|
|
|
|
|
set_rpath = "$ORIGIN",
|
|
|
|
|
)
|
|
|
|
|
|
2023-01-02 14:28:25 +00:00
|
|
|
copy_to_directory(
|
|
|
|
|
name = "sandbox",
|
|
|
|
|
srcs = [
|
2025-07-08 09:25:25 +00:00
|
|
|
":libpjrt_cuda_so",
|
|
|
|
|
"@cuda_cudart",
|
|
|
|
|
"@cuda_cupti",
|
|
|
|
|
"@cuda_nvcc",
|
|
|
|
|
"@cuda_nvrtc",
|
|
|
|
|
"@cuda_nvtx",
|
|
|
|
|
"@cudnn",
|
2025-08-12 13:32:18 +00:00
|
|
|
"@libnvshmem",
|
2025-07-08 09:25:25 +00:00
|
|
|
"@libcublas",
|
|
|
|
|
"@libcufft",
|
|
|
|
|
"@libcusolver",
|
|
|
|
|
"@libcusparse",
|
|
|
|
|
"@libnvjitlink",
|
|
|
|
|
"@nccl",
|
2025-03-26 11:18:29 +00:00
|
|
|
"@zlib1g",
|
2025-07-08 09:25:25 +00:00
|
|
|
"@zml//runtimes/cuda:zmlxcuda",
|
2023-01-02 14:28:25 +00:00
|
|
|
],
|
2025-03-26 11:18:29 +00:00
|
|
|
replace_prefixes = {
|
|
|
|
|
"nvidia/nccl/lib": "lib",
|
|
|
|
|
"nvvm/lib64": "lib",
|
2025-07-08 09:25:25 +00:00
|
|
|
"libpjrt_cuda_so": "lib",
|
2025-03-26 11:18:29 +00:00
|
|
|
"lib/x86_64-linux-gnu": "lib",
|
2025-07-08 09:25:25 +00:00
|
|
|
"runtimes/cuda": "lib",
|
2025-03-26 11:18:29 +00:00
|
|
|
},
|
|
|
|
|
add_directory_to_runfiles = False,
|
2023-01-02 14:28:25 +00:00
|
|
|
include_external_repositories = ["**"],
|
|
|
|
|
)
|
|
|
|
|
|
2025-03-26 11:18:29 +00:00
|
|
|
cc_library(
|
2023-01-02 14:28:25 +00:00
|
|
|
name = "libpjrt_cuda",
|
|
|
|
|
data = [":sandbox"],
|
|
|
|
|
deps = [
|
2025-03-26 11:18:29 +00:00
|
|
|
"@cuda_cudart//:cuda",
|
2023-01-02 14:28:25 +00:00
|
|
|
],
|
2025-03-26 11:18:29 +00:00
|
|
|
linkopts = [
|
|
|
|
|
# Defer function call resolution until the function is called
|
|
|
|
|
# (lazy loading) rather than at load time.
|
|
|
|
|
#
|
|
|
|
|
# This is required because we want to let downstream use weak CUDA symbols.
|
|
|
|
|
#
|
|
|
|
|
# We force it here because -z,now (which resolve all symbols at load time),
|
|
|
|
|
# is the default in most bazel CC toolchains as well as in certain linkers.
|
|
|
|
|
"-Wl,-z,lazy",
|
|
|
|
|
],
|
|
|
|
|
visibility = ["@zml//runtimes/cuda:__subpackages__"],
|
2023-01-02 14:28:25 +00:00
|
|
|
)
|