Skip to content

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

Closed

Description

@jeberger

What happened?

llama-cli and llama-bench rev. 9379d3c 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

Activity

  1. added
    high severityUsed to report high severity bugs in llama.cpp (Malfunctioning hinder important workflow)
    on Sep 4, 2024
  2. jeberger commented on Sep 4, 2024

    @jeberger
    Author

    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).

  3. homenkovo commented on Sep 20, 2024

    @homenkovo

    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.

  4. github-actions commented on Nov 4, 2024

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

  5. theSoberSobber commented on Jan 4, 2025

    @theSoberSobber

    Why was this closed, I suffered the same error as this in current latest commit and fixed it using @homenkovo's solution

  6. watkyns commented on Feb 4, 2025

    @watkyns

    having same issue with b4628 and homenkovo's solution can fix it

  7. 0dminnimda commented on Feb 5, 2025

    @0dminnimda

    No need to modify no files, a simple command line argument is enough:

    -DCMAKE_CXX_FLAGS=-D_WIN32_WINNT=0x602
    
  8. robbyvids commented on Feb 12, 2025

    @robbyvids

    not worked on win 11 for me, using python script. Memory more than enough, it happen when loading to gpu or cpu.

    llama_model_load: error loading model: PrefetchVirtualMemory unavailable

  9. vishal-ahirwar commented on Feb 17, 2025

    @vishal-ahirwar

    No need to modify no files, a simple command line argument is enough:

    -DCMAKE_CXX_FLAGS=-D_WIN32_WINNT=0x602
    

    thanks it worked for me

  10. Pigoomy commented on May 4, 2025

    @Pigoomy

    I encountered the same PrefetchVirtualMemory unavailable error with llama-cpp-python on Windows. Disabling memory mapping via use_mmap=False resolved it instantly!
    Hope this saves someone hours of debugging🛠️

  11. julmich commented on Jun 4, 2025

    @julmich

    PrefetchVirtualMemory unavailable error with llama-cpp on Windows - b5514 sources - compiling with llvm-mingw_64

    this CMAKE line share from 0dminnimda above fix the issue
    -DCMAKE_CXX_FLAGS=-D_WIN32_WINNT=0x602

  12. reopened this on Jun 4, 2025
  13. added
    bugSomething isn't working
    and removed on Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghigh severityUsed to report high severity bugs in llama.cpp (Malfunctioning hinder important workflow)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions