You've got a cutting-edge RTX 5060 Ti. CUDA is installed. PyTorch reports that CUDA is available. Everything should work.
Then you run your script and hit this:
RuntimeError: CUDA error: no kernel image is available for execution on the device
PyTorch sees the GPU but can't run code on it. Why?
🤯 The Real Problem
This error means your PyTorch installation includes CUDA support, but not for your specific GPU architecture.
Blackwell GPUs (like the 5060 Ti) use a compute capability called sm_120
. The PyTorch binaries you're installing from pip were not built with support for sm_120
, even if they were compiled against CUDA 12.6.
No sm_120
in the build = no working CUDA kernels = crash.
✅ Quick Fix: Force CPU Mode
If you want to get running immediately, you can bypass the GPU.
Look for code like this:
model.to("cuda" if torch.cuda.is_available() else "cpu")
Change it to:
model.to("cpu")
Or hard-code your app's logic to avoid trying to use the GPU at all. In one project, I had to do:
models = {False: KModel().to("cpu").eval()}
You can also force:
CUDA_AVAILABLE = False
This disables GPU execution entirely - slower, but at least it works.
🛠 Long-Term Fix (Recommended): Install a Custom .whl
with GPU Support
Here's how to fix this the right way-by installing a version of PyTorch compiled with support for sm_120
(your GPU's compute architecture).
🔍 Step-by-Step: Finding and Installing the Right .whl
Go to the official PyTorch
.whl
page for CUDA 12.8
This is the hidden goldmine:
→ https://download.pytorch.org/whl/cu128/torch_stable.htmlMatch your Python version
For example:Python 3.11 → look for
cp311
Python 3.10 → look for
cp310
Download these three files (all must match the same CUDA & Python version):
torch-*.whl
torchvision-*.whl
(optional)
torchaudio-*.whl
Install them in order using pip
Replace the paths with where you saved the files:
pip install torch-2.7.0+cu128-cp311-cp311-win_amd64.whl
pip install torchvision-0.22.0+cu128-cp311-cp311-win_amd64.whl
pip install torchaudio-2.7.0+cu128-cp311-cp311-win_amd64.whl
Verify CUDA works:
python -c "import torch; print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0))"
You should see something like:
True
NVIDIA GeForce RTX 5060 Ti
🧠 Why This Works
The standard pip install torch
only gives you builds for older architectures (like sm_86
or sm_90
). But Blackwell (your 50xx GPU) uses sm_120
, which isn't included in the default PyTorch wheels.
Luckily, PyTorch 2.7+ does support sm_120
, it's just not distributed via pip yet. That's why downloading the .whl
manually from the PyTorch site solves the problem.
📦 Still Not Working?
You're on the wrong Python version. The
.whl
must match your Python version exactly.Wrong CUDA version. These
.whl
files are for CUDA 12.8. You must have the CUDA 12.8 runtime (or later) available.Using a weird IDE or environment. Try using a fresh venv and run from PowerShell or Terminal.
🧪 Final Tip: Lock the Setup
Once it's working, save your setup in a requirements.txt
so you can replicate it later:
pip freeze > requirements.txt
Now you're set. Your RTX 50xx is finally working the way it should.