SIGILL on Old CPUs with llama.cpp: What to Do When an Instruction Set Does Not Match
Scope: running llama.cpp's
llama-serverormainon an older x86 server, workstation, or VM, where the program crashes at startup or during model loading with onlyIllegal instruction (core dumped)on the terminal, shell exit code 132, or a SIGILL mention; the same binary works on a newer machine. Organized as "confirm SIGILL - explain root cause - two fix paths - acceptance".
Short answer: SIGILL is not a broken model or a broken llama.cpp - it means this binary contains machine instructions the current CPU cannot execute. The common case: the binary was compiled on a new machine with AVX, AVX2, or FMA enabled (build systems default to optimizing for "the current system"), then copied to an old CPU that lacks them; when execution reaches such an instruction the CPU cannot decode it and the OS sends SIGILL. The llama.cpp official build doc and ggml's CMakeLists.txt are the sources every parameter name here was checked against. Wherever a default or number appears it is marked "verify against your version", because these switches evolve.
1. First confirm it is SIGILL, not a missing library or model
The first step is to capture the exact exit reason rather than guessing from "it exits on startup". On Linux run the program directly and check the shell:
Seeing Illegal instruction or exit code 132 basically confirms SIGILL. For harder evidence, grab the kernel log or disassemble:
dmesg | tail -20 | grep -i llama # the kernel may log the faulting IP and instruction
# or inspect the crash under gdb
gdb --args ./llama-server -m model.gguf
# after run, if it stops on an avx/avx2-related instruction, it is an instruction-set issue
Separate a few easily confused cases: error while loading shared libraries means a missing dynamic library, unrelated to instruction sets; a missing-model or bad-GGUF-format error is a model problem; a crash only after running a while on a specific operator may be runtime dispatch or a virtualization XSAVE/XCR0 issue (covered later). Only "immediate Illegal instruction at startup or load time" fits compile-time instruction-set incompatibility.
2. Root cause: build-time instruction sets versus the runtime CPU
Why does a binary that is fine on a new machine die on an old one? The key is llama.cpp's default build policy. The official Docker/build docs state: "By default llama.cpp will be built for the hardware that is connected to the system at that time". In ggml's CMakeLists.txt this is governed by GGML_NATIVE, described as ggml: optimize the build for the current system, defaulting to ON on non-cross builds and OFF when cross-compiling or when SOURCE_DATE_EPOCH is set. In other words, the default build fully exploits the build machine's CPU features, and the produced binary may contain instructions the old machine lacks.
The official ggml/CMakeLists.txt shows these x86 instruction-set switches (current-version definitions; verify against your version):
option(GGML_NATIVE "ggml: optimize the build for the current system" ${GGML_NATIVE_DEFAULT})
option(GGML_SSE42 "ggml: enable SSE 4.2" ${INS_ENB})
option(GGML_AVX "ggml: enable AVX" ${INS_ENB})
option(GGML_AVX2 "ggml: enable AVX2" ${INS_ENB})
option(GGML_BMI2 "ggml: enable BMI2" ${INS_ENB})
option(GGML_FMA "ggml: enable FMA" ${INS_ENB})
option(GGML_F16C "ggml: enable F16C" ${INS_ENB})
option(GGML_AVX512 "ggml: enable AVX512F" OFF)
Two details matter. First, AVX, AVX2, FMA, and F16C defaults follow INS_ENB, which is derived from GGML_NATIVE - when native optimization is on, those switches take the build machine's optimized path. Second, GGML_FMA and GGML_F16C are defined only under non-MSVC compilers, because in MSVC they are implied by AVX2/AVX512. If the old CPU lacks any of these and the binary executes the corresponding instruction, SIGILL can follow.
3. Path 1: use a compatibility prebuilt binary
The quickest route is not to compile at all but to swap in a binary built for old CPUs. llama.cpp's release page offers prebuilt artifacts for many platforms; prefer one explicitly labeled compatible with older CPUs (for example a generic cpu build without AVX/AVX512 in its name). After swapping, do not go straight to production - run one minimal inference first:
But a prebuilt is not automatically safe. A real GitHub issue (kherud/java-llama.cpp#25) reports prebuilt x86 linux libs using EVEX encoding for AVX instructions, causing SIGILL on CPUs without AVX512; later llama.cpp releases also carried a fix (release notes mention disabling LTO so cross-module optimization cannot inline architecture-specific instructions into the feature-detection code). "A prebuilt can also bite" is not hypothetical, so always test after swapping. If it still crashes, go to Path 2.
4. Path 2: rebuild from source with incompatible instruction sets off
When a compatible prebuilt is unavailable or still crashes, build one yourself with the extensions disabled. Use CMake per the official build docs; the core is turning GGML_NATIVE off plus explicitly disabling what the old CPU lacks:
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
cmake -B build \
-DGGML_NATIVE=OFF \
-DGGML_AVX=OFF \
-DGGML_AVX2=OFF \
-DGGML_FMA=OFF \
-DGGML_F16C=OFF
cmake --build build --config Release
A potentially confusing point: the GGML_NATIVE=OFF example in the official build doc appears in the CUDA section's Non-Native Builds paragraph, which says the resulting binary runs on all CUDA GPUs. The option's meaning is general - turning off build-machine-specific optimization makes the artifact more portable; combining it with the x86 switches is the standard recipe for an old-CPU build. With those switches off the binary uses a more basic instruction path: best compatibility but noticeably lower throughput, since vector capability goes unused. This is trading performance for runnability - do not expect new-machine speeds after disabling AVX.
If you are unsure which switch to turn off, bisect: first set only GGML_NATIVE=OFF; if it still crashes, disable AVX2, AVX, FMA, F16C one by one based on the CPU model. Check which instructions a CPU supports via lscpu Flags or the flags line of /proc/cpuinfo. One caveat: the widely copied make LLAMA_AVX=0 LLAMA_AVX2=0 ... form belongs to the old Makefile build system; the project has moved to CMake, so old commands may be inert on newer versions - verify against your version's official docs.
5. Path 3: runtime dispatch and virtualization boundaries
Newer llama.cpp versions include runtime CPU feature detection and dynamic dispatch (one binary carries several instruction-set implementations and binds the matching one at startup via CPUID); ideally a single binary automatically takes the conservative path on an old machine. A few boundaries still produce SIGILL in practice:
First, CPUID reports hardware capability, not whether the OS has enabled the matching extended register state. An issue notes ggml's CPU feature check consults CPUID but not the OS XSAVE/XCR0 state, so in restricted containers, some virtualization platforms, or custom kernels, executing VEX/EVEX instructions can still SIGILL even when CPUID claims support. If the old machine is a VM or container, it is worth checking separately. Second, LTO (link-time optimization) can inline architecture-specific instructions into feature-detection code across modules; official release notes record a fix for this, showing it is a real trigger. Third, emulation layers such as Windows on ARM translating x86 binaries or Rosetta have their own signal semantics, so do not carry the Linux reasoning over verbatim. The common thread is "the instruction is in the binary but the execution path was not correctly gated": prefer a compatibility build, then upgrade to a version carrying the relevant fixes.
6. Acceptance checklist before calling it done
- Confirmed SIGILL via
echo $?(132) ordmesg/ gdb, not a missing library or model error - Recorded the old CPU model and
lscpuflags, confirming it lacks the enabled AVX/AVX2/FMA instructions - After swapping to a compatibility prebuilt, ran a minimal inference
-p "hello" -n 8to verify loading no longer crashes - If rebuilding, followed your version's official docs with
-DGGML_NATIVE=OFFand disabled the needed switches; kept the build command on file - Aware of the cost: better compatibility but lower inference speed; ran a performance regression
- If the host is a VM/container, considered XSAVE/XCR0 and LTO boundaries or upgraded to a release with the relevant fixes
- Recorded llama.cpp version, build method, and old CPU model for later comparison at the "verify against your version" boundaries
One last principle: SIGILL means "the CPU does not recognize this instruction", not "the software cannot find the model". Confirm the signal on the old machine, then decide whether it is compile-time incompatibility or a runtime dispatch boundary; a compatibility build first, a source rebuild with instructions off second, usually restores operation. For quantization tiers and model size see LLM Quantization in Practice on this site, the overall local setup in the Ollama Deployment Handbook, and stack trade-offs in Inference Engine Selection.