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:

  

      github.com
  

  
    pytorch/pytorch/blob/e795315c638228d4170f3797356c09a70b2ed4cd/torch/csrc/cuda/Module.cpp#L183-L190



      
      
          PyObject * THCPModule_getCompiledVersion(PyObject *self, PyObject *noargs)
          {
          #if defined(USE_ROCM)
            return THPUtils_packInt64((int64_t) ROCM_VERSION);
          #else
            return THPUtils_packInt64((int64_t) CUDA_VERSION);
          #endif
          }
      
    
  


  

  
    
    
  

  


and

  

      github.com
  

  
    pytorch/pytorch/blob/e795315c638228d4170f3797356c09a70b2ed4cd/caffe2/core/common_gpu.h#L98



      
      
          
          
#if defined(CUDA_VERSION) && CUDA_VERSION >= 10000
          #define CAFFE2_CUDA_PTRATTR_MEMTYPE type
          #else
          #define CAFFE2_CUDA_PTRATTR_MEMTYPE memoryType
          #endif
          
          
/**
           * A runtime function to report the cuda version that Caffe2 is built with.
           */
          inline int CudaVersion() {
          #if defined(USE_ROCM)
            return ROCM_VERSION;
          #else
            return CUDA_VERSION;
          #endif
          }
          
          
/**
           * Returns the number of devices.
           */
      
    
  


  

  
    
    
  

  


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.