Skip to content

Conversation

@cloudhan
Copy link
Collaborator

Together with #431, this should fix hermetic ctk13 with clang as cuda compiler driver.

cd tests/integration/toolchain_redist_json
sed -i 's/12\.6\.3/13\.0\.0/g' MODULE.bazel
export USE_BAZEL_VERSION=8.5.0
export CUDA_COMPILER_USE_CC_TOOLCHAIN=true
bazel build --repo_env=CC=clang --@rules_cuda//cuda:compiler=clang --@rules_cuda//cuda:archs=sm_89 :use_rule

produces

ERROR: /home/cloud/rules_cuda/tests/integration/toolchain_redist_json/BUILD.bazel:10:13: Compiling external/rules_cuda_examples+/basic/kernel.cu failed: (Exit 1): clang failed: error executing CudaCompile command (from target //:use_rule) /usr/lib/llvm-22/bin/clang -x cu '--cuda-gpu-arch=sm_89' '--cuda-path=external/rules_cuda++toolchain+cuda_nvcc_v13.0.48/nvcc' '-frandom-seed=bazel-out/k8-fastbuild/bin/_objs/use_rule/kernel.pic.o' ... (remaining 76 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
clang: error: cannot find libdevice for sm_89; provide path to different CUDA installation via '--cuda-path', or pass '-nocudalib' to build without linking with libdevice
clang: error: cannot find CUDA installation; provide its path via '--cuda-path', or pass '-nocudainc' to build without CUDA includes
clang: error: cannot find CUDA installation; provide its path via '--cuda-path', or pass '-nocudainc' to build without CUDA includes
Target //:use_rule failed to build

The reason behind this is https://github.com/llvm/llvm-project/blob/6de6f7b46bda0fef45b997d05fe57e046f60e4df/clang/lib/Driver/ToolChains/Cuda.cpp#L206-L290

The <ctk_root> must have the structure as follows,

<ctk_root>/bin/
<ctk_root>/include/
<ctk_root>/nvvm/libdevice/libdevice.10.bc

then <ctk_root> can be treat as a valid CTK installation.

We fake it by patching nvvm repo which contains libdevice.10.bc with empty bin/ and include/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants