
How to Fix 'RuntimeError: CUDA error: no kernel image is available for execution on the device' in PyTorch on Linux
Diagnose a CUDA kernel image error before changing wheels or drivers
The error CUDA error: no kernel image is available for execution on the device can indicate that the failing kernel lacks usable GPU code for the target architecture. The kernel might belong to an application-specific extension, not necessarily to the PyTorch core distribution. A matching entry in a general build-architecture list is not proof that the failing custom kernel was compiled and launched successfully.
Corrected November 13, 2026: An older version interpreted a missing exact architecture string as definitive evidence that the whole PyTorch wheel was incompatible, prescribed unconditional reinstall/cache deletion, and announced that a single matrix multiplication proved native SASS support. It also asserted PTX guaranteed all future GPUs. Those unverified or overbroad claims and destructive commands are removed.
The NVIDIA CUDA compatibility guide explains that binaries can include compiled cubin code and forward-compatible PTX. If no compatible kernel image can be selected or generated for the target device, a kernel launch can fail. That does not identify which package provided the failing kernel from the generic error text alone.
1. Record the device and package environment
The PyTorch get_device_capability reference defines the returned major/minor CUDA compute capability. The separate get_arch_list reference documents architectures the PyTorch library was compiled for, not every separately installed extension.
The following script is a read-only diagnostics proposal for an environment with PyTorch already installed; it was not executed on a GPU by this publisher:
import sys
import torch
print("Python:", sys.version.split()[0])
print("torch:", torch.__version__)
print("torch CUDA build:", torch.version.cuda)
print("CUDA available:", torch.cuda.is_available())
print("PyTorch build architecture list:", torch.cuda.get_arch_list())
if torch.cuda.is_available():
for device_id in range(torch.cuda.device_count()):
print("device", device_id, torch.cuda.get_device_name(device_id))
print("compute capability", torch.cuda.get_device_capability(device_id))
else:
print("No CUDA device available to query in this environment")
Collect the original traceback and identify whether the failed call belongs to torch, FlashAttention, a custom C++ extension or a model-serving library. Record the exact package/extension version and CUDA build. Do not infer complete binary compatibility from a single string, nor infer that any CUDA operation will work merely because torch.cuda.is_available() is true.
2. Classify what needs changing
| Observation | Evidence to check | What not to conclude |
|---|---|---|
| Core PyTorch operation fails | Installed wheel, driver, device architecture and exact failing operation | A reinstall from a historic CUDA URL will certainly fix it |
| Only a particular native extension fails | Its wheel identity, compiled architectures, source build logs | The PyTorch core wheel must lack support |
| Device is newer than build targets | Compatible cubin/PTX presence, toolkit and driver support | Adding +PTX guarantees execution on every future GPU |
| Error happens inside a container | The runtime GPU visibility and extension provenance | Docker build necessarily compiled an unsupported generic fallback |
| Package starts and another kernel works | Reproduce the original failing kernel with controlled inputs | A successful unrelated matmul proves the original extension works |
The PyTorch C++/CUDA extension reference documents TORCH_CUDA_ARCH_LIST for building extensions, including explicit target capabilities and a +PTX suffix. It does not change architectures already compiled into an installed wheel by setting an environment variable at runtime. Rebuilds must use the exact project’s supported package and compiler versions.
3. Understand cubin and PTX scope
The NVIDIA Blackwell compatibility guide describes binary and PTX compatibility behavior. PTX can permit JIT compilation on later compatible GPU architectures, but real execution still depends on the available code path, CUDA/driver compatibility and use of architecture-specific features.
PyTorch’s extension documentation distinguishes explicitly compiled targets from the optional PTX forward-compatibility suffix. For a known, owned extension, inspect its build instructions and logs before selecting a supported target. Do not paste a universal architecture list into every model-serving extension.
In particular, a driver message about an unsupported GPU code object does not imply a GPU memory-management unit searched for and failed to find a file. Avoid model-specific architecture tables without an upstream, version-scoped hardware source.
4. Safe, staged remediation
- Observe first. Save the exact failing stack trace, GPU model, device capability, driver, PyTorch version and extension identity.
- Pin compatibility. Consult the intended PyTorch release and extension release notes for supported Python, CUDA, compiler and architecture combinations.
- Isolate failures. Determine whether only the extension fails or a core PyTorch operation also fails. A different successful kernel does not certify the failing kernel.
- Build only when necessary. If you own a custom extension and its build truly omits the target GPU, review
TORCH_CUDA_ARCH_LISTin the official extension reference and create a controlled build in a new environment. - Avoid destructive guesses. Do not blindly run
pip cache purge, force-uninstall shared PyTorch packages, override a system-wide CUDA symlink or kill GPU workloads. - Verify the failing operation. On authorized hardware, rerun a small, bounded reproduction of the original operation, synchronize the GPU where needed to expose deferred errors, and preserve exact logs.
The PyTorch CUDA semantics documentation describes CUDA execution behavior and memory diagnostics. GPU kernel tests can allocate memory and must run only with appropriate device ownership.
5. What this article establishes
This is a diagnostic decision guide, not a package migration script or a verified RTX 4090/H100/Blackwell execution report. The code displays available metadata on the user’s own system; it does not allocate a 4096×4096 CUDA tensor or certify SASS presence. No kernel performance or universal wheel compatibility claims are made.
Primary references
- PyTorch CUDA device compute capability
- PyTorch library build architecture list
- PyTorch CUDA extension architecture/compilation documentation
- PyTorch CUDA semantics
- NVIDIA Blackwell cubin and PTX compatibility
Independent source review: November 13, 2026. Original publication date and representative image preserved.