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?
Ps:
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;
AT_CUDA_CHECK(cudaRuntimeGetVersion(&runtimeVersion));

for the driver version:

int version;
AT_CUDA_CHECK(cudaDriverGetVersion(&version));

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

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