Open ZhenshengLee opened 1 month ago
I've found that in the doc page
rules_cuda_dependencies(toolkit_path)
Populate the dependencies for rules_cuda. This will setup workspace dependencies (other bazel rules) and local toolchains. Name Description Default Value toolkit_path Optionally specify the path to CUDA toolkit. If not specified, it will be detected automatically.
Is there an example to show how to use it correctly?
I think you are configuring it correctly. The root problem is the cross compiling is not addressed in this rule at the moment. So exec_compatible_with
for tools and target_compatible_with
for runtime are assumed to be the same, but they are not enforced so it is workaroundable.
I think you are configuring it correctly. The root problem is the cross compiling is not addressed in this rule at the moment.
OK, I will keep the issue open.
brief
NOTE: in the default platform, which is x86_64(k8) toolchain , the compile and linking works. I wonder if it's a bug or just a misconfiguration during usage of this repo?
environment
bazel: version7.0.2 cctoolchain: //bazel/toolchains/v5l (a custom cc toolchain for cross compile in aarch64, like https://github.com/f0rmiga/gcc-toolchain/blob/main/toolchain/cc_toolchain_config.bzl)
repro steps
simply compile the basic example with cu_library and report the following errors. NOTE: in the default platform, which is x86_64(k8) toolchain , the compile works.
considerations
skipping incompatible bazel-out/aarch64-dbg/bin/_solib_aarch64-buildroot-linux-gnu/_U@@local_Ucuda_S_S_Clibcudart.so.11.0___Ucuda_Slib64/libcudart.so.11.0 when searching for -l:libcudart.so.11.0
which means the cuda libraries is still the lib64 version in
usr/local/cuda/lib64
.actually the cuda libraries may be installed in other dirs and may consist multiple arch version. especially in nvidia AGX machines.
https://github.com/NVIDIA/DL4AGX/blob/9a4f60c2847d32e81372b9a2165299a3b65eabf1/CONTRIBUTING.md?plain=1#L201-L205
related info
there is an old version of cuda toolchain config which supports multiplatform_cpu compile in bazel, but the CROSSTOOL is outdated and not available in the latest version of bazel.
https://github.com/NVIDIA/DL4AGX/tree/master
EDIT: there already has an issue talking about resolving multiple version of cuda libraries, but I don't think the issue resolved by design https://github.com/bazel-contrib/rules_cuda/issues/113
workaround(works)
add the library path manually should compile the binary successfully.