How to check torch gpu compatibility without initializing CUDA?
Older GPUs don't seem to support torch in spite of recent cuda versions.
In my case the crash has the following error:
/home/maxs/dev/mdb/venv38/lib/python3.8/site-packages/torch/cuda/__init__.py:83: UserWarning: 
    Found GPU%d %s which is of cuda capability %d.%d.
    PyTorch no longer supports this GPU because it is too old.
    The minimum cuda capability supported by this library is %d.%d.
    
  warnings.warn(old_gpu_warn.format(d, name, major, minor, min_arch // 10, min_arch % 10))
WARNING:lightwood-16979:Exception: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1. when training model: &lt;lightwood.model.neural.Neural object at 0x7f9c34df1e80&gt;
Process LearnProcess-1:13:
Traceback (most recent call last):
  File &quot;/home/maxs/dev/mdb/venv38/sources/lightwood/lightwood/model/helpers/default_net.py&quot;, line 59, in forward
    output = self.net(input)
  File &quot;/home/maxs/dev/mdb/venv38/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File &quot;/home/maxs/dev/mdb/venv38/lib/python3.8/site-packages/torch/nn/modules/container.py&quot;, line 139, in forward
    input = module(input)
  File &quot;/home/maxs/dev/mdb/venv38/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File &quot;/home/maxs/dev/mdb/venv38/lib/python3.8/site-packages/torch/nn/modules/linear.py&quot;, line 96, in forward
    return F.linear(input, self.weight, self.bias)
  File &quot;/home/maxs/dev/mdb/venv38/lib/python3.8/site-packages/torch/nn/functional.py&quot;, line 1847, in linear
    return torch._C._nn.linear(input, weight, bias)
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

This happens in spite of:
assert torch.cuda.is_available() == True
torch.version.cuda == '10.2'

How can I check for an older GPU that doesn't support torch without actually try/catching a tensor-to-gpu transfer? The transfer initializes cuda, which wastes like 2GB of memory, something I can't afford since I'd be running this check in dozens of processes, all of which would then waste 2GB of memory extra due to the initialization.

Based on the code in torch.cuda.__init__ that was actually throwing the error the following check seems to work:
import torch
from torch.cuda import device_count, get_device_capability

def is_cuda_compatible():
    compatible_device_count = 0
    if torch.version.cuda is not None:
        for d in range(device_count()):
            capability = get_device_capability(d)
            major = capability[0]
            minor = capability[1]
            current_arch = major * 10 + minor
            min_arch = min((int(arch.split(&quot;_&quot;)[1]) for arch in torch.cuda.get_arch_list()), default=35)
            if (not current_arch &lt; min_arch
                    and not torch._C._cuda_getCompiledVersion() &lt;= 9000):
                compatible_device_count += 1

    if compatible_device_count &gt; 0:
        return True
    return False

Not sure if it's 100% correct but putting it out here for feedback and in case anybody else needs it.
