cocktailpeanut / dalai

The simplest way to run LLaMA on your local machine
https://cocktailpeanut.github.io/dalai
13.1k stars 1.42k forks source link

Mac M2 supported? I have # EXIT { exitCode: 132, signal: 0 } #140

Open Kent-Min opened 1 year ago

tgcandido commented 1 year ago

M2 here, no problem running alpaca nor llama

DanielDavis05 commented 1 year ago

All models work on M1 Max

AnonimusJack commented 1 year ago

Check if you're trying to run the commands through "rosetta", I had that issue and it built the executables on x86_64 instead of arm64 and obviously it didn't work. Also use the "debug" checkbox to get a better error message.

To check if your terminal runs in "rosetta" mode use this command:

uname -m

If it says x86_64 run this command to switch to native arm64:

arch -arm64 /bin/zsh

PS. You'll need to reinstall the model/s.

Hope it helps 🙏

DrEdwardPCB commented 1 year ago

I have just got dalai works on my own M2 Max macbook, here by the steps to get dalai setup.

  1. ensure nodejs and python are installed
  2. use the command to create the folder structure required mkdir -p ~/dalai/alpaca/models
  3. install the alpaca model npx dalai alpaca install 7B <-switch to other model if wanted
  4. cd ~/dalai/alpaca
  5. remove the built alpaca by make clean
  6. rebuild the alpaca with make quantize then make main
  7. run npx dalai serve

After that you should see dalai up and running

troubleshoot

in case there are errors during make, try to run make clean and then make ggml.o and make utils.o and run again from step 6

How does this work.

some how the dalai install command is not intelligent enough to determine the architecture of the Host Machine. it uses its virtual env that when Makefile tries to run uname -m will return x86_64 instead of arm64. If the alpaca is built with x86_64, M2 Max which runs arm64 will response illegal instruction:4. To mitigate this error, just have to rebuild the alpaca with correct Arch with your own terminal should fix all problem.

downside

since dalai install command will wipe the whole away the alpaca folder on each call. Every time installing new model weight requires redo of step 5 to 7