coreylowman / cudarc

Safe rust wrapper around CUDA toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best way to support different CUDA version?

djmarcin opened this issue · comments

If I want to use a different CUDA version than the bindgen is currently built against, should I just rerun bindgen on my system?

Would there be interest in a PR to make this crate dynamically generate bindings based on the cuda installation on the developer's system?

I was thinking about this recently actually - I was thinking we would have bindgens for all the major versions in the repo, and add feature flags for which one to activate.

E.g. you'd put cudarc = { version = "...", default-features = false, features = ["cuda-12.1"] }

And then each of the different bindgens would only be activated for it's specific version.

Thoughts?

I think that’s probably a reasonable approach, although linking would still use the version of CUDA present on the machine, regardless of the feature flag, I think?

There may be some parts of the safe API that need to be modified or disabled if they depend on code from certain versions, and since you can’t (at least last time I looked at something like this) have a <= operator on feature flags in a cfg macro, it can get a little unwieldy to specify as versions grow. Possibly solvable with some indirection in build.rs? This issue would still exist even if bindgen reran against the locally installed CUDA, too.