RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Troubleshooting
  4. /Python: wheel build failed / 'Failed building wheel for X'
fatal✓Editorial·Reviewed May 2026

Python wheel build failed — fix compiler, deps, or fall back to prebuilt

Wheel build failures in pip install almost always trace to: missing compiler (gcc / MSVC), missing system headers (Python.h, CUDA), or a Rust-based package without the Rust toolchain. Fix compiler first, then verify wheel availability.

pip installflash-attnvllmexllamav2tokenizersany pip package needing build
By Fredoline Eruo · Last verified 2026-05-08

Diagnostic order — most likely first

#1

Compiler missing (gcc on Linux, MSVC on Windows)

Diagnose

Error: 'gcc not found' or 'cl.exe not found.' Pip can't compile C extensions.

Fix

Linux: `sudo apt install build-essential python3-dev`. macOS: `xcode-select --install`. Windows: install Visual Studio Build Tools 2022 (workload: Desktop development with C++).

#2

CUDA headers missing for CUDA-using build

Diagnose

Error: 'cuda.h not found' or 'cuda_runtime.h missing.' Building flash-attn / xformers / custom CUDA without the toolkit installed.

Fix

Install CUDA Toolkit (not just driver): `sudo apt install nvidia-cuda-toolkit` (Linux) or download CUDA 12.4 installer from nvidia.com (Windows). Set `CUDA_HOME=/usr/local/cuda-12.4` before retrying.

#3

Rust toolchain missing for Rust-based build (tokenizers, hf-transfer)

Diagnose

Error mentions 'cargo not found' or 'rustc missing.' Hugging Face's `tokenizers` and `hf-transfer` packages are Rust-based.

Fix

Install Rust: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` (Linux/macOS) or use rustup-init.exe on Windows. Source the cargo env and retry.

#4

Wheel exists for your platform but pip didn't find it

Diagnose

Falling back to source build means pip didn't find a precompiled wheel. Check the project's release page for available wheels.

Fix

Specify the index explicitly. For flash-attn: `pip install flash-attn --no-build-isolation`. For vllm: `pip install vllm` should pull a wheel; if not, your Python/CUDA combo isn't precompiled.

#5

Insufficient RAM during compile (parallel jobs OOM)

Diagnose

Build starts then OOMs. Each gcc parallel job uses 1-2 GB. Default `-j` count too high for available RAM.

Fix

Lower parallelism: `MAX_JOBS=4 pip install flash-attn --no-build-isolation` (or even MAX_JOBS=2 on tight RAM). Compilation takes longer but won't OOM.

#6

ABI mismatch with installed PyTorch

Diagnose

Build succeeds but import fails: 'undefined symbol' or 'ABI mismatch.' The wheel was built against a different PyTorch version.

Fix

Match versions. Reinstall PyTorch first to a known-good version, then rebuild the dependent package against it. Or use `--no-cache-dir` to force fresh build.

Frequently asked questions

Why doesn't pip find a prebuilt wheel for my platform?

Wheels are platform-specific (OS + Python version + CPU arch). Bleeding-edge Python (3.13+) or unusual platforms (ARM Linux) often don't have prebuilt wheels for niche packages. The fallback is source build.

Should I use uv instead of pip?

Yes for most workflows. uv resolves + installs 10-100x faster than pip, has better dependency resolution, and ships better error messages. `pip install uv` then use `uv pip install <package>`.

Why does flash-attn always need to compile?

Flash-attn ships prebuilt wheels for common combos (CUDA 12.4 + Python 3.10/3.11/3.12 + Torch 2.4/2.5) but not all. If your combo isn't matched, you compile from source. Takes 5-15 minutes; uses significant RAM.

Related troubleshooting

torch.cuda.is_available() returns False

PyTorch falsely reporting no CUDA is the most common Python ML setup failure. The cause is almost always: wrong PyTorch wheel for your CUDA version, or a CPU-only build accidentally installed.

vLLM: CUDA version mismatch / 'no kernel image is available for execution'

vLLM ships pre-built wheels against specific CUDA versions. When your system CUDA differs, you get cryptic kernel-image errors. Here's the version matrix and the fix order.

llama.cpp build failed (CUDA / Metal / Vulkan flags rejected)

Most llama.cpp build failures trace to a missing toolkit (CUDA, Metal, Vulkan SDK), wrong compiler version, or a stale CMake cache. Diagnose in order: PATH first, CMake version second, GCC/MSVC third.

When the fix is hardware

A surprising fraction of troubleshooting tickets resolve to: this card doesn't have enough VRAM for what you're asking it to do. If you're hitting OOM after every reasonable fix, or your GPU genuinely can't fit the model you need, it's upgrade time:

  • Best GPU for local AI
  • Best laptop for local AI
  • Best Mac for local AI

Where next?

All troubleshooting guides
OrBest GPU for local AIWill it run on my hardware?