Returns GPU compute capability as integer (e.g. 86 for SM 8.6), or 0 if no GPU.
()
| 74 | |
| 75 | |
| 76 | def _detect_gpu_sm() -> int: |
| 77 | """Returns GPU compute capability as integer (e.g. 86 for SM 8.6), or 0 if no GPU.""" |
| 78 | try: |
| 79 | import torch |
| 80 | if torch.cuda.is_available(): |
| 81 | major, minor = torch.cuda.get_device_capability(0) |
| 82 | return major * 10 + minor |
| 83 | except Exception: |
| 84 | pass |
| 85 | return 0 |