rules_cuda
rules_cuda copied to clipboard
Why `@rules_cuda//cuda:runtime` flag rather than respecting `--dynamic_mode`
Bazel already has a flag (--dynamic_mode) to allow controlling of static vs dynamic linking. I think it's feasible to apply this to the cuda runtime. Why not use this flag? It's surprising that there's a separate flag and that the bazel flag is not respected.
If you're OK with switching to use the built-in --dynamic_mode I'd be happy to open a PR to implement the change.
Thanks!
This is from https://github.com/bazel-contrib/rules_cuda/blob/152bbbc9a8680d18b38ca4fba2f9bdb09ee68862/cuda/BUILD#L91-L103, this repo originally is a subtree of tf_runtime and then a full rewrite is carried out starts (with an independent source tree root).
@cloudhan are you OK with me removing the flag and just relying on --dynamic_mode? Or if not, then having the default be to respect --dynamic_mode?
I don't know the reason behind it actually, so let's keep it as is for now. Maybe @chsigg can explain it a bit?
The flag is also introduced to inject a different CUDA runtime, e.g. one that dynamically loads the real CUDA runtime and forwards the calls. That can be independent though of (by default) dynamically switching between linking against static or dynamic runtime. I don't know how to dynamically switch between the two based on --dynamic_mode. You could probably use cc_import(), but you might need to wrap that in a cc_library() still for the existing linkopts arguments. This might be worthwhile doing, although NVIDIA strongly advises against linking dynamic CUDA runtime.
If you assign this to me I can work on making it respect --dynamic_mode by default, and we can leave the flag to override.