Cross compilation is a common practice for embedded and autonomous driving systems. As the time of this writing, configuration of Clang-based Bazel toolchains w/ CUDA support on Linux was still challenging. As John Millikin pointed out(Ref):
It assumes background knowledge in cross compilation, plus experience with Bazel's Starlark extension language, build rules, and repository definitions. Most users of Bazel shouldn't need to care about the details of compiler toolchains, but this is important stuff for maintainers of language rules.
This project was an attempt to address this issue, by integrating existing work by grailbio/bazel-toolchain and tf_runtime/rules_cuda.
Please refer to scripts in the tests/scripts/run_tests
directory for examples.
Bazel 5.3 or newer (might work with older versions). This project was tested w/ Bazel 5.3.2 on Ubuntu 18.04 and 20.04.
For my own use case, this project was tailored to work w/ LLVM/Clang >= 13.0.1 on Ubuntu releases >= 18.04 (Windows and MacOS Support present in grailbio/bazel-toolchain was removed).
It seems the rules_cuda
project inside tensorflow/runtime has evolved into an independent, full-fedged CUDA rules for Bazel project.
So we might switch to using this repo as cuda_library
implementation if possible.
This work was impossible without these excellent projects besides Bazel.
- The LLVM toolchain for Bazel project
- The tf_runtime/rules_cuda: CUDA rules for Bazel project.