CUDA and CuDNN version for libtorch

Hi @ptrblck

I want to know what libtorch API that we can use to get the CUDA and CuDNN version?
Right now I have a project that using both opencv DNN and Libtorch, but I keep getting warning because unmatch cudnn version. I use pre-built libtorch library.

best regards,
Albert Christianto

For cuDNN:

long cudnn_version = at::detail::getCUDAHooks().versionCuDNN();

for CUDA runtime:

int runtimeVersion;

for the driver version:

int version;

In case you want to use checks in the code you could also use e.g.:

#if defined(CUDA_VERSION) && CUDA_VERSION >= 11200