PR #16882: Symlink hermetic cuda headers to permit clang cuda version detection

Imported from GitHub PR https://github.com/openxla/xla/pull/16882

Fixes #16877
Copybara import of the project:

--
1ff356ac0870002b369c3ec09547aae2a62c70e2 by tchatow <tchatow@users.noreply.github.com>:

Symlink hermetic cuda headers to permit clang cuda version detection

Fixes #16877

Merging this change closes #16882

PiperOrigin-RevId: 679764212
This commit is contained in:
tchatow 2024-09-27 16:18:36 -07:00 committed by TensorFlower Gardener
parent 4e9171c74a
commit 3f4b2fda6f
5 changed files with 16 additions and 0 deletions

View File

@ -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"

View File

@ -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."""
@ -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):

View File

@ -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"

View File

@ -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"

View File

@ -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."""
@ -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):