Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CUDA dependencies from jaxlib OSS wheel. #20534

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xla/backends/profiler/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package_group(

tsl_gpu_library(
name = "profiler_backends",
add_gpu_deps_for_oss = False,
# copybara:uncomment compatible_with = ["//buildenv/target:non_prod"],
visibility = internal_visibility(["//xla:internal"]),
deps = [
"//xla/backends/profiler/cpu:host_tracer",
Expand Down
4 changes: 2 additions & 2 deletions xla/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,15 @@ cc_library(
"@tsl//tsl/profiler/lib:profiler_session",
"@tsl//tsl/profiler/lib:traceme",
"@tsl//tsl/profiler/protobuf:profiled_instructions_proto_cc",
] + if_cuda([
] + if_google(if_cuda([
"@local_config_cuda//cuda:cuda_headers",
]) + if_rocm([
# keep sorted
"@local_config_rocm//rocm:hip",
"@local_config_rocm//rocm:rocm_headers",
]) + if_cuda_or_rocm([
":py_client_gpu", # TODO(b/337876408): remove after migration to plugin
]) + if_google(["@com_google_protobuf//:any_cc_proto"]),
]) + ["@com_google_protobuf//:any_cc_proto"]),
)

cc_library(
Expand Down
2 changes: 2 additions & 0 deletions xla/tsl/distributed_runtime/coordination/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ cc_library(
tsl_gpu_library(
name = "coordination_service_impl",
srcs = ["coordination_service.cc"],
add_gpu_deps_for_oss = False,
deps = [
":coordination_client",
":coordination_service",
Expand Down Expand Up @@ -141,6 +142,7 @@ tsl_gpu_library(
name = "coordination_service_agent",
srcs = ["coordination_service_agent.cc"],
hdrs = ["coordination_service_agent.h"],
add_gpu_deps_for_oss = False,
deps = [
":coordination_client",
":coordination_service_error_util",
Expand Down
31 changes: 21 additions & 10 deletions xla/tsl/tsl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,12 @@ def tf_openmp_copts():
"//conditions:default": [],
})

def tsl_gpu_library(deps = None, cuda_deps = None, copts = tsl_copts(), **kwargs):
def tsl_gpu_library(
deps = None,
cuda_deps = None,
copts = tsl_copts(),
add_gpu_deps_for_oss = True,
**kwargs):
"""Generate a cc_library with a conditional set of CUDA dependencies.

When the library is built with --config=cuda:
Expand All @@ -373,6 +378,7 @@ def tsl_gpu_library(deps = None, cuda_deps = None, copts = tsl_copts(), **kwargs
'--config=cuda' is passed to the bazel command line.
deps: dependencies which will always be linked.
copts: copts always passed to the cc_library.
add_gpu_deps_for_oss: Whether to add gpu deps for OSS too.
**kwargs: Any other argument to cc_library.
"""
if not deps:
Expand All @@ -381,19 +387,24 @@ def tsl_gpu_library(deps = None, cuda_deps = None, copts = tsl_copts(), **kwargs
cuda_deps = []

kwargs["features"] = kwargs.get("features", []) + ["-use_header_modules"]
deps = deps + if_cuda(cuda_deps)
deps = deps + (if_cuda(cuda_deps) if add_gpu_deps_for_oss else if_google(if_cuda(cuda_deps)))
if "default_copts" in kwargs:
copts = kwargs["default_copts"] + copts
kwargs.pop("default_copts", None)
all_cuda_deps = if_cuda([
clean_dep("//xla/tsl/cuda:cudart"),
"@local_config_cuda//cuda:cuda_headers",
]) + if_rocm([
"@local_config_rocm//rocm:hip",
"@local_config_rocm//rocm:rocm_headers",
])
all_cuda_copts = if_cuda(["-DGOOGLE_CUDA=1", "-DNV_CUDNN_DISABLE_EXCEPTION"]) + if_rocm(["-DTENSORFLOW_USE_ROCM=1"])
if not add_gpu_deps_for_oss:
all_cuda_deps = if_google(all_cuda_deps)
all_cuda_copts = if_google(all_cuda_copts)
cc_library(
deps = deps + if_cuda([
clean_dep("//xla/tsl/cuda:cudart"),
"@local_config_cuda//cuda:cuda_headers",
]) + if_rocm([
"@local_config_rocm//rocm:hip",
"@local_config_rocm//rocm:rocm_headers",
]),
copts = (copts + if_cuda(["-DGOOGLE_CUDA=1", "-DNV_CUDNN_DISABLE_EXCEPTION"]) + if_rocm(["-DTENSORFLOW_USE_ROCM=1"]) + if_xla_available(["-DTENSORFLOW_USE_XLA=1"]) + if_mkl(["-DINTEL_MKL=1"]) + if_enable_mkl(["-DENABLE_MKL"]) + if_tensorrt(["-DGOOGLE_TENSORRT=1"])),
deps = deps + all_cuda_deps,
copts = (copts + all_cuda_copts + if_xla_available(["-DTENSORFLOW_USE_XLA=1"]) + if_mkl(["-DINTEL_MKL=1"]) + if_enable_mkl(["-DENABLE_MKL"]) + if_tensorrt(["-DGOOGLE_TENSORRT=1"])),
**kwargs
)

Expand Down