Skip to content

Commit

Permalink
PR #16882: Symlink hermetic cuda headers to permit clang cuda version…
Browse files Browse the repository at this point in the history
… detection

Imported from GitHub PR #16882

Fixes #16877
Copybara import of the project:

--
1ff356a by tchatow <[email protected]>:

Symlink hermetic cuda headers to permit clang cuda version detection

Fixes #16877

Merging this change closes #16882

COPYBARA_INTEGRATE_REVIEW=#16882 from tchatow:patch-1 1ff356a
PiperOrigin-RevId: 679764212
  • Loading branch information
tchatow authored and Google-ML-Automation committed Sep 27, 2024
1 parent ccaeb74 commit ca8bb43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ build:cuda_clang --copt=-Qunused-arguments
# major release. Example: sm_80 kernels can run on sm_89 GPUs but
# not on sm_90 GPUs. compute_80 kernels though can also run on sm_90 GPUs.
build:cuda_clang --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_80,sm_89,compute_90"
# Permit newer CUDA versions than Clang is aware of
build:cuda_clang --copt="-Wno-unknown-cuda-version"
# Set lld as the linker.
build:cuda_clang --host_linkopt="-fuse-ld=lld"
build:cuda_clang --host_linkopt="-lm"
Expand Down
2 changes: 2 additions & 0 deletions third_party/tsl/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ build:cuda_clang --copt=-Qunused-arguments
# major release. Example: sm_80 kernels can run on sm_89 GPUs but
# not on sm_90 GPUs. compute_80 kernels though can also run on sm_90 GPUs.
build:cuda_clang --repo_env=HERMETIC_CUDA_COMPUTE_CAPABILITIES="sm_60,sm_70,sm_80,sm_89,compute_90"
# Permit newer CUDA versions than Clang is aware of
build:cuda_clang --copt="-Wno-unknown-cuda-version"
# Set lld as the linker.
build:cuda_clang --host_linkopt="-fuse-ld=lld"
build:cuda_clang --host_linkopt="-lm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ def _create_libcuda_symlinks(
repository_ctx.symlink(nvidia_driver_path, "lib/libcuda.so.1")
repository_ctx.symlink("lib/libcuda.so.1", "lib/libcuda.so")

def _create_cuda_header_symlinks(repository_ctx):
if repository_ctx.name == "cuda_nvcc":
repository_ctx.symlink("../cuda_cudart/include/cuda.h", "include/cuda.h")

def use_local_path(repository_ctx, local_path, dirs):
# buildifier: disable=function-docstring-args
"""Creates repository using local redistribution paths."""
Expand Down Expand Up @@ -339,6 +343,7 @@ def _use_downloaded_cuda_redistribution(repository_ctx):
repository_ctx,
lib_name_to_version_dict,
)
_create_cuda_header_symlinks(repository_ctx)
repository_ctx.file("version.txt", major_version)

def _cuda_repo_impl(repository_ctx):
Expand Down

0 comments on commit ca8bb43

Please sign in to comment.