ggerganov / llama.cpp

LLM inference in C/C++
MIT License
65.56k stars 9.4k forks source link

Bug: MinGW build fails to load models with "error loading model: PrefetchVirtualMemory unavailable" #9311

Open jeberger opened 3 weeks ago

jeberger commented 3 weeks ago

What happened?

llama-cli and llama-bench rev. 9379d3cc1718 built with MinGW fails to load models:

llama_model_load: error loading model: PrefetchVirtualMemory unavailable
llama_load_model_from_file: failed to load model

Name and Version

./bin/llama-cli --version version: 3664 (9379d3c) built with for x86_64-w64-mingw32

What operating system are you seeing the problem on?

Windows

Relevant log output

llama_model_load: error loading model: PrefetchVirtualMemory unavailable
llama_load_model_from_file: failed to load model
jeberger commented 3 weeks ago

I believe the issue was introduced when the source was reorganized into folders. I'm able to work around it by adding the following to the top level CMakeLists.txt:

if (MINGW)
    add_compile_definitions(_WIN32_WINNT=0x602)
endif()

so I believe the equivalent code is missing from some CMakeLists.txt files in subfolders (I tried adding it to examples/llama-bench/CMakeLists.txt but that wasn't enough to fix the issue).

homenkovo commented 1 week ago

I had a similar problem. I just replaced #define _WIN32_WINNT 0x0601 with #define _WIN32_WINNT 0x0A00 in the <_mingw.h> file and it worked.