llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

Illegal hardware instruction in quantize step

Open tunglee35 opened this issue 1 year ago • 2 comments

  • Ran into this error on a Macbook Pro M1
./quantize ./models/7B/ggml-model-f16.bin ./models/7B/ggml-model-q4_0.bin 2
[1]    18452 illegal hardware instruction  ./quantize ./models/7B/ggml-model-f16.bin ./models/7B/ggml-model-q4_0.bin 2
  • What I've tried:

    • Run main on the model-f16, still have the same error
    • Convert the 13B model, still same error in quantize step
  • Env: Darwin Tungs-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 x86_64

tunglee35 avatar Mar 12 '23 09:03 tunglee35

What does cc --version and c++ --version say?

prusnak avatar Mar 12 '23 10:03 prusnak

This error happens when binary is compiled for x86_64 instead of arm64.

This is common mistake if you are compiling under conda like environment.

Check binary quantize with: file quantize

On Apple Silicon Macs it should print: quantize: Mach-O 64-bit executable arm64

If it shows x86_64 then you have to recompile after exiting conda environment: make clean make

brozkrut avatar Mar 12 '23 11:03 brozkrut

@prusnak it said

Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

tunglee35 avatar Mar 13 '23 02:03 tunglee35

Solved by re-install conda env. Thanks guys

tunglee35 avatar Mar 13 '23 06:03 tunglee35

@brozkrut

Thank you, it works as you said.

bowbowbow avatar Mar 14 '23 12:03 bowbowbow

@brozkrut I got the error in Windows 7:

ERROR: /app/.devops/tools.sh: line 40 6 Illegal instruction ./main $arg2

when I executed :

--quantize "/models/7B/ggml-model-f16.bin" "/models/7B/ggml-model-q4_0.bin" 2

and I checked my quantize file:

quantize: ELF 64-bit LSB shared object, x86-64, version 1 <GNU/Linux> ...... for GNU/Linux 3.2.0, not stripped

But the architecture of docker image named ghcr.io/ggerganov/llama.cpp:full is amd64:

docker image ghcr.io/ggerganov/llama.cpp:full|grep Architecture "Architecture": "amd64"

and my environment is:

Docker Toolbox 1.13.1 docker client: 1.13.1 os/arch: windows 7 /amd64 docker server:19.03.12 os/arch:ubuntu 22.04 /amd64

SO I'M CONFUSED: 1 Must I re-compile quantize? 2 How to re-compile if I use docker image? 3 Is there anywhere that I can download directly?

JerryYao80 avatar May 29 '23 02:05 JerryYao80

This error happens when binary is compiled for x86_64 instead of arm64.

This is common mistake if you are compiling under conda like environment.

Check binary quantize with: file quantize

On Apple Silicon Macs it should print: quantize: Mach-O 64-bit executable arm64

If it shows x86_64 then you have to recompile after exiting conda environment: make clean make can you explain me clearly

amanreddy77 avatar Jan 19 '24 12:01 amanreddy77

Solved by re-install conda env. Thanks guys

can you please explain me

amanreddy77 avatar Jan 19 '24 16:01 amanreddy77