ggerganov / llama.cpp

LLM inference in C/C++
MIT License
68.33k stars 9.81k forks source link

windows on arm ,build with openblas / vulkan #9823

Open wmx-github opened 1 month ago

wmx-github commented 1 month ago

Blas is accelerated by compiling GGML provided, so in the llama.cpp/ggml/src/CMakeLists.txt file ,

Refer to GGML_BLAS:

if (GGML_BLAS)

# omit

set(GGML_HEADERS_BLAS .. /include/ggml-blas.h)

set(GGML_SOURCES_BLAS ggml-blas.cpp)

list(APPEND GGML_EXTRA_LIBS_PRIVATE ${BLAS_LIBRARIES})

list(APPEND GGML_EXTRA_INCLUDES     ${BLAS_INCLUDE_DIRS})

# omit

endif()

add the following code in this line of code if GGML_BLAS front BLAS_ROOT is your openblas path

# add custom blas
if (CUSTOM_BLAS)
    set(BLAS_ROOT "C:/workspace/program/openblas")
    set(BLAS_INCLUDE_DIRS
        "${BLAS_ROOT}/include/"
        "${BLAS_ROOT}/include/openblas"
    )
    set(BLAS_LIBRARIES "${BLAS_ROOT}/lib/openblas.lib")
    list(APPEND GGML_CDEF_PUBLIC GGML_USE_BLAS)

    set(GGML_HEADERS_BLAS ../include/ggml-blas.h)
    set(GGML_SOURCES_BLAS ggml-blas.cpp)

    list(APPEND GGML_EXTRA_LIBS_PRIVATE ${BLAS_LIBRARIES})
    list(APPEND GGML_EXTRA_INCLUDES     ${BLAS_INCLUDE_DIRS})
endif()

Then compile, specifying CUSTOM_BLAS=ON :

cmake -B build -DGGML_BLAS=OFF  -DCUSTOM_BLAS=ON
cmake --build build --config Release
wmx-github commented 1 month ago

build openblas for windows on arm can refer to : How to build OpenBLAS for Windows on ARM64

or

源码编译 openblas for windows on arm

wmx-github commented 1 month ago

This library provides binaries compiled for windows on arm :

https://github.com/turingevo/llama.cpp-build/releases

build width openblas sysyem: windows on arm64 , snapdragon 8cx gen3 openblas : OpenBLAS-0.3.28 build for windows on arm

build width vulkan sysyem: windows on arm64 , snapdragon 8cx gen3 vulkan: Vulkan SDK 1.3.296.0 for windows on arm