Metadata-Version: 2.4
Name: torch-cuda-compat
Version: 0.2.0
Summary: Which PyTorch wheel runs on which NVIDIA GPU, with the vendor's own words as evidence
Author: referencesource.org
License: CC0-1.0
Project-URL: Homepage, https://referencesource.org/torch-cuda-compat/
Project-URL: Source, https://referencesource.org/gpu-cuda-pytorch-compatibility/
Keywords: pytorch,cuda,nvidia,gpu,compute-capability,wheels
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# torch-cuda-compat

Tells you which PyTorch wheel runs on a given NVIDIA GPU, and shows you the
line on NVIDIA's or PyTorch's own page that says so.

```console
$ pip install torch-cuda-compat
$ torch-cuda-compat "RTX 5090" 2.7
GeForce RTX 5090 — compute capability 12.0
PyTorch 2.7

  no   CUDA 11.8   this build stops at compute capability 9.0; the card is
                   12.0, so the wheel installs and then fails at the first
                   kernel launch
  no   CUDA 12.6   this build stops at compute capability 9.0; the card is
                   12.0, so the wheel installs and then fails at the first
                   kernel launch
  YES  CUDA 12.8   compute capability 12.0 is compiled into this build

pip install torch --index-url https://download.pytorch.org/whl/cu128
needs an NVIDIA driver >= 525
```

```python
>>> from torch_cuda_compat import resolve
>>> r = resolve("RTX 5090", "2.7")
>>> r["recommended"]["cuda"]
'12.8'
>>> r["recommended"]["install"]
'pip install torch --index-url https://download.pytorch.org/whl/cu128'
>>> r["recommended"]["evidence"][0]["quote"]
'TORCH_CUDA_ARCH_LIST="7.5;8.0;8.6;9.0;10.0;12.0+PTX"'
```

## The thing this gets right

A PyTorch wheel only runs on a GPU whose **compute capability was compiled into
it**, and that list is not the same as "CUDA supports this card". An RTX 5090 is
compute capability 12.0; the `cu126` build of PyTorch 2.7 was compiled for 5.0
through 9.0. It installs perfectly and then dies at the first kernel launch.
`cu128` was compiled for 12.0 and works.

Three rules decide it, and all three are applied here:

- **Compiled in.** The wheel's `TORCH_CUDA_ARCH_LIST` names the card's compute
  capability outright.
- **Binary compatibility.** A cubin runs on any later minor revision of the same
  major architecture. This is why `cu126`, compiled for 8.0 and 8.6 and never
  mentioning 8.9, runs fine on an RTX 4090 — the case a hand-written table
  usually gets wrong. It does **not** cross a major: an sm_100 cubin
  (data-centre Blackwell, a B200) does not run on an sm_120 card (consumer
  Blackwell, a 5090), even though both are called Blackwell.
- **`+PTX`.** An architecture marked `+PTX` ships as JIT source too, so the
  driver compiles it at first launch for any newer card. It works, after a pause
  the first time.

Where no source states which architectures a build was compiled for, `runs` is
`None` — *not known*, rather than *no*.

## Every value cites its source

```python
>>> r = resolve("RTX 4090", "2.6")
>>> r["gpu_evidence"]["source"]
'https://developer.nvidia.com/cuda/gpus'
>>> r["gpu_evidence"]["quote"]          # the row the 8.9 was read out of
'8.9 | NVIDIA L4 NVIDIA L40 NVIDIA L40S | ... GeForce RTX 4090'
>>> {e["source"] for e in r["recommended"]["evidence"]}
{'https://raw.githubusercontent.com/pytorch/pytorch/release/2.6/.ci/manywheel/build_cuda.sh',
 'https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html'}
```

That is the point of the package. The values come from NVIDIA's CUDA GPU list,
NVIDIA's CUDA Toolkit release notes and PyTorch's `RELEASE.md` and per-release
build scripts, and each one carries the URL and the verbatim quote it was read
from, so you can check it instead of trusting it. Nothing here is a value
somebody typed out from memory.

## What is in it

441 NVIDIA GPUs with their compute capability, and 45 (PyTorch release, CUDA
build) pairings covering PyTorch 1.12 through 2.14 and CUDA 11.3 through 13.2 —
each with the Python versions, the cuDNN version, the wheel index URL, the
compiled architecture list and the minimum NVIDIA driver. About 300 KB of JSON,
no dependencies, and no network access at runtime.

## API

| | |
|---|---|
| `resolve(gpu, torch)` | the answer: every CUDA build of that release, each with `runs`, `why` and its evidence, plus `recommended` |
| `compute_capability(gpu)` | the GPU table entry; raises `GPUNotFound` rather than guessing |
| `architectures(pairing)` | the compute capabilities a build was compiled for |
| `gpus()`, `pairings()`, `data()` | the shipped dataset |

GPU names are matched leniently: `"RTX 5090"`, `"rtx-5090"` and the
`"NVIDIA GeForce RTX 5090"` that `torch.cuda.get_device_name()` returns all find
the same card. An ambiguous name raises and lists the candidates instead of
picking one.

## Data and licence

Browse the dataset, one page per record, at
**<https://referencesource.org/gpu-cuda-pytorch-compatibility/>**.

The compilation is CC0-1.0. The underlying facts come from PyTorch (BSD-3-Clause)
and NVIDIA's technical documentation; each value cites its source, and short
attributed quotes are all that is reproduced.

A JavaScript port shipping the identical data is on npm as
[`torch-cuda-compat`](https://www.npmjs.com/package/torch-cuda-compat).
