Query CUDA version at runtime

I wonder if there’s a way to query the CUDA version LibTorch has been compiled with at runtime.
I found a few references like:

and

But the first returns a PyObject* that’s not practical to work with and the second is a header file, so I expect it to be filled with whatever CUDA_VERSION is defined when I am compiling my program.

I think there might not be. The version.h would be the most natural place (as in closest match to version.py, the canonical source of information from Python) and it does not have the information.

To my mind, it would be useful to get
tools/setup_helpers/gen_version_header.py
to generate the same things as
tools/generate_torch_version.py.

Maybe you could open an issue to discuss this.

Best regards

Thomas

Thanks very much for your answer @tom !
Just opened a ‘Feature Request’ issue in the GitHub repository.
Here’s the link for future reference: