Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when starting: "llama_init_from_file: failed to load model" #18

Closed
mkinney opened this issue Apr 7, 2023 · 13 comments · Fixed by #57
Closed

Error when starting: "llama_init_from_file: failed to load model" #18

mkinney opened this issue Apr 7, 2023 · 13 comments · Fixed by #57

Comments

@mkinney
Copy link
Contributor

mkinney commented Apr 7, 2023

I'm getting an error when starting:

(venv) sweet gpt4all-ui % python app.py
llama_model_load: loading model from './models/gpt4all-lora-quantized-ggml.bin' - please wait ...
./models/gpt4all-lora-quantized-ggml.bin: invalid model file (bad magic [got 0x67676d66 want 0x67676a74])
	you most likely need to regenerate your ggml files
	the benefit is you'll get 10-100x faster load times
	see https://github.com/ggerganov/llama.cpp/issues/91
	use convert-pth-to-ggml.py to regenerate from original pth
	use migrate-ggml-2023-03-30-pr613.py if you deleted originals
llama_init_from_file: failed to load model
Checking discussions database...
Ok
llama_generate: seed = 1680843169

system_info: n_threads = 8 / 16 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | VSX = 0 |
zsh: segmentation fault  python app.py

I have validated the md5sum matches:

sweet gpt4all-ui % md5sum models/gpt4all-lora-quantized-ggml.bin
387eeb7cba52aaa278ebc2fe386649b1  models/gpt4all-lora-quantized-ggml.bin
sweet gpt4all-ui % cat models/gpt4all-lora-quantized-ggml.bin.md5
387eeb7cba52aaa278ebc2fe386649b1
@rafatzbr
Copy link

rafatzbr commented Apr 7, 2023

Same error here.

@mkinney
Copy link
Contributor Author

mkinney commented Apr 7, 2023

I should add I'm on an intel mac. The gpt4all chat's gpt4all-lora-quantized-OSX-intel works for me.

@rafatzbr
Copy link

rafatzbr commented Apr 7, 2023

I'm running on Linux. Also was able to run gpt4all-lora-quantized-Linux-x86

@rafatzbr
Copy link

rafatzbr commented Apr 7, 2023

I also tried to run this code:

`from pyllamacpp.model import Model

def new_text_callback(text: str):
print(text, end="")

model = Model(ggml_model='./models/gpt4all-lora-quantized-ggml.bin', n_ctx=512)
model.generate("Once upon a time, ", n_predict=55, new_text_callback=new_text_callback, n_threads=8)`

and got the same error, which points to an invalid file.

@ParisNeo
Copy link
Owner

ParisNeo commented Apr 7, 2023

Yes you are right. The model provided by Nomic-ai is not compatible with windows. I'll ask them to provide a working version soon.

In the meanwhile you can download the model and convert it by yourself as presented in:
https://github.com/nomic-ai/pyllamacpp

Thanks for your understanding.

@ParisNeo
Copy link
Owner

ParisNeo commented Apr 8, 2023

A new version of the installer fixes this issue.
Please confirm that it works for you and close the issue.

@zpdg
Copy link

zpdg commented Apr 8, 2023

A new version of the installer fixes this issue. Please confirm that it works for you and close the issue.

I am using Ubuntu. The same error occurs. "./models/gpt4all-lora-quantized-ggml.bin: invalid model file (bad magic [got 0x67676d66 want 0x67676a74]).......llama_init_from_file: failed to load model"

@BoQsc
Copy link

BoQsc commented Apr 8, 2023

Windows 10 Home, Intel, NVIDIA laptop. All recent github clone. Selected to download model using browser. Downloading was successful. bad magic error.

llama_model_load: loading model from './models/gpt4all-lora-quantized-ggml.bin' - please wait ...
./models/gpt4all-lora-quantized-ggml.bin: invalid model file (bad magic [got 0x67676d66 want 0x67676a74])
        you most likely need to regenerate your ggml files
        the benefit is you'll get 10-100x faster load times
        see https://github.com/ggerganov/llama.cpp/issues/91
        use convert-pth-to-ggml.py to regenerate from original pth
        use migrate-ggml-2023-03-30-pr613.py if you deleted originals
llama_init_from_file: failed to load model
llama_generate: seed = 1680974915

@ngonzalezromero
Copy link

MacOSx Ventura Intel same error
`llama_model_load: loading model from './models/gpt4all-lora-quantized-ggml.bin' - please wait ...
./models/gpt4all-lora-quantized-ggml.bin: invalid model file (bad magic [got 0x67676d66 want 0x67676a74])
you most likely need to regenerate your ggml files
the benefit is you'll get 10-100x faster load times
see ggml-org/llama.cpp#91
use convert-pth-to-ggml.py to regenerate from original pth
use migrate-ggml-2023-03-30-pr613.py if you deleted originals
llama_init_from_file: failed to load model
llama_generate: seed = 1680976601

system_info: n_threads = 8 / 12 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 1 | VSX = 0 |
./run.sh: line 43: 14830 Segmentation fault: 11 python app.py`

@ParisNeo
Copy link
Owner

ParisNeo commented Apr 8, 2023

For people using windows try running install.bat. The script downloads the right model, does the conversion and everything.
The model you download should be converted to the new llama.cpp format.
Take a look at the install.bat code.
I will change the install.sh to do the same.

@BoQsc
Copy link

BoQsc commented Apr 8, 2023

Windows 10

Conversion seem to fix this.
./models/gpt4all-lora-quantized-ggml.bin: invalid model file (bad magic [got 0x67676d66 want 0x67676a74])

"gpt4all-ui/convert.cmd"

@ECHO OFF
echo Converting the model to the new format
if not exist tmp/llama.cpp git clone https://github.com/ggerganov/llama.cpp.git tmp\llama.cpp
move models\gpt4all-lora-quantized-ggml.bin models\gpt4all-lora-quantized-ggml.bin.original
python tmp\llama.cpp\migrate-ggml-2023-03-30-pr613.py models\gpt4all-lora-quantized-ggml.bin.original models\gpt4all-lora-quantized-ggml.bin
echo The model file (gpt4all-lora-quantized-ggml.bin) has been fixed.

PAUSE

Then just do the run.bat and have lots of patience.

@ngonzalezromero
Copy link

I fixed the error by just adding lines on run.sh fix the error
`
echo "Converting the model to the new format"

if [ ! -d "tmp/llama.cpp" ]
then
git clone https://github.com/ggerganov/llama.cpp.git tmp/llama.cpp
fi

mv models/gpt4all-lora-quantized-ggml.bin models/gpt4all-lora-quantized-ggml.bin.original

python tmp/llama.cpp/migrate-ggml-2023-03-30-pr613.py models/gpt4all-lora-quantized-ggml.bin.original models/gpt4all-lora-quantized-ggml.bin
`

@ngonzalezromero
Copy link

happy to create a new PR with this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants