cmake : build with any BLAS compatible library (#927)

* Build with any BLAS library

* ci: Removed explicit CUDA nvcc path
This commit is contained in:
Alexey Kharlamov 2023-05-20 19:23:45 +01:00 committed by GitHub
parent 429b9785c0
commit 041be06d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 60 deletions

92
.gitignore vendored
View File

@ -1,46 +1,46 @@
*.o *.o
*.a *.a
.cache/ .cache/
.coreml/ .coreml/
.test/ .test/
.vs/ .vs/
.vscode/ .vscode/
.DS_Store .DS_Store
build/ build/
build-em/ build-em/
build-debug/ build-debug/
build-release/ build-release/
build-static/ build-static/
build-cublas/ build-cublas/
build-no-accel/ build-no-accel/
build-sanitize-addr/ build-sanitize-addr/
build-sanitize-thread/ build-sanitize-thread/
/main /main
/stream /stream
/command /command
/talk /talk
/talk-llama /talk-llama
/bench /bench
/quantize /quantize
arm_neon.h arm_neon.h
sync.sh sync.sh
libwhisper.a libwhisper.a
libwhisper.so libwhisper.so
compile_commands.json compile_commands.json
examples/arm_neon.h examples/arm_neon.h
examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/ examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
extra/bench-gg.txt extra/bench-gg.txt
models/*.mlmodel models/*.mlmodel
models/*.mlmodelc models/*.mlmodelc
models/*.mlpackage models/*.mlpackage
bindings/java/.gradle/ bindings/java/.gradle/
bindings/java/.idea/ bindings/java/.idea/
.idea/ .idea/

View File

@ -59,9 +59,11 @@ if (APPLE)
option(WHISPER_COREML "whisper: enable Core ML framework" OFF) option(WHISPER_COREML "whisper: enable Core ML framework" OFF)
option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF) option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF)
else() else()
option(WHISPER_OPENBLAS "whisper: support for OpenBLAS" OFF) option(WHISPER_BLAS "whisper: use BLAS libraries" OFF)
option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF) option(WHISPER_BLAS_VENDOR "whisper: BLAS library vendor" Generic)
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF) option(WHISPER_OPENBLAS "whisper: prefer OpenBLAS" OFF)
option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
endif() endif()
option(WHISPER_PERF "whisper: enable perf timings" OFF) option(WHISPER_PERF "whisper: enable perf timings" OFF)
@ -127,19 +129,29 @@ if (APPLE)
endif() endif()
if (WHISPER_OPENBLAS) if (WHISPER_OPENBLAS)
find_library(OPENBLAS_LIB set(WHISPER_BLAS_VENDOR "OpenBLAS")
NAMES openblas libopenblas set(WHISPER_BLAS ON)
)
if (OPENBLAS_LIB)
message(STATUS "OpenBLAS found")
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${OPENBLAS_LIB})
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
else()
message(WARNING "OpenBLAS not found")
endif()
endif() endif()
if (WHISPER_BLAS)
set(BLA_STATIC 1)
set(BLA_VENDOR ${WHISPER_BLAS_VENDOR})
# set(BLA_PREFER_PKGCONFIG 1)
set(BLA_SIZEOF_INTEGER 8)
find_package(BLAS)
if(BLAS_FOUND)
message(STATUS "BLAS compatible library found")
message(STATUS "Libraries ${BLAS_LIBRARIES}")
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
include_directories(${BLAS_INCLUDE_DIRS})
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
else()
message(WARNING "BLAS library was not found")
endif()
endif ()
if (WHISPER_CUBLAS) if (WHISPER_CUBLAS)
cmake_minimum_required(VERSION 3.17) cmake_minimum_required(VERSION 3.17)