Skip to content

Commit 041be06

Browse files
authored
cmake : build with any BLAS compatible library (#927)
* Build with any BLAS library * ci: Removed explicit CUDA nvcc path
1 parent 429b978 commit 041be06

File tree

2 files changed

+69
-57
lines changed

2 files changed

+69
-57
lines changed

.gitignore

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
*.o
2-
*.a
3-
.cache/
4-
.coreml/
5-
.test/
6-
.vs/
7-
.vscode/
8-
.DS_Store
9-
10-
build/
11-
build-em/
12-
build-debug/
13-
build-release/
14-
build-static/
15-
build-cublas/
16-
build-no-accel/
17-
build-sanitize-addr/
18-
build-sanitize-thread/
19-
20-
/main
21-
/stream
22-
/command
23-
/talk
24-
/talk-llama
25-
/bench
26-
/quantize
27-
28-
arm_neon.h
29-
sync.sh
30-
libwhisper.a
31-
libwhisper.so
32-
compile_commands.json
33-
34-
examples/arm_neon.h
35-
examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
36-
examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
37-
examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
38-
39-
extra/bench-gg.txt
40-
41-
models/*.mlmodel
42-
models/*.mlmodelc
43-
models/*.mlpackage
44-
bindings/java/.gradle/
45-
bindings/java/.idea/
46-
.idea/
1+
*.o
2+
*.a
3+
.cache/
4+
.coreml/
5+
.test/
6+
.vs/
7+
.vscode/
8+
.DS_Store
9+
10+
build/
11+
build-em/
12+
build-debug/
13+
build-release/
14+
build-static/
15+
build-cublas/
16+
build-no-accel/
17+
build-sanitize-addr/
18+
build-sanitize-thread/
19+
20+
/main
21+
/stream
22+
/command
23+
/talk
24+
/talk-llama
25+
/bench
26+
/quantize
27+
28+
arm_neon.h
29+
sync.sh
30+
libwhisper.a
31+
libwhisper.so
32+
compile_commands.json
33+
34+
examples/arm_neon.h
35+
examples/whisper.objc/whisper.objc.xcodeproj/xcshareddata
36+
examples/whisper.objc/whisper.objc.xcodeproj/xcuserdata/
37+
examples/whisper.objc/whisper.objc.xcodeproj/project.xcworkspace/xcuserdata
38+
39+
extra/bench-gg.txt
40+
41+
models/*.mlmodel
42+
models/*.mlmodelc
43+
models/*.mlpackage
44+
bindings/java/.gradle/
45+
bindings/java/.idea/
46+
.idea/

CMakeLists.txt

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ if (APPLE)
5959
option(WHISPER_COREML "whisper: enable Core ML framework" OFF)
6060
option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF)
6161
else()
62-
option(WHISPER_OPENBLAS "whisper: support for OpenBLAS" OFF)
63-
option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
64-
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
62+
option(WHISPER_BLAS "whisper: use BLAS libraries" OFF)
63+
option(WHISPER_BLAS_VENDOR "whisper: BLAS library vendor" Generic)
64+
option(WHISPER_OPENBLAS "whisper: prefer OpenBLAS" OFF)
65+
option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF)
66+
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
6567
endif()
6668

6769
option(WHISPER_PERF "whisper: enable perf timings" OFF)
@@ -127,18 +129,28 @@ if (APPLE)
127129
endif()
128130

129131
if (WHISPER_OPENBLAS)
130-
find_library(OPENBLAS_LIB
131-
NAMES openblas libopenblas
132-
)
133-
if (OPENBLAS_LIB)
134-
message(STATUS "OpenBLAS found")
132+
set(WHISPER_BLAS_VENDOR "OpenBLAS")
133+
set(WHISPER_BLAS ON)
134+
endif()
135+
136+
if (WHISPER_BLAS)
137+
set(BLA_STATIC 1)
138+
set(BLA_VENDOR ${WHISPER_BLAS_VENDOR})
139+
# set(BLA_PREFER_PKGCONFIG 1)
140+
set(BLA_SIZEOF_INTEGER 8)
141+
find_package(BLAS)
135142

136-
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${OPENBLAS_LIB})
143+
if(BLAS_FOUND)
144+
message(STATUS "BLAS compatible library found")
145+
message(STATUS "Libraries ${BLAS_LIBRARIES}")
137146
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
147+
148+
include_directories(${BLAS_INCLUDE_DIRS})
149+
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
138150
else()
139-
message(WARNING "OpenBLAS not found")
151+
message(WARNING "BLAS library was not found")
140152
endif()
141-
endif()
153+
endif ()
142154

143155
if (WHISPER_CUBLAS)
144156
cmake_minimum_required(VERSION 3.17)

0 commit comments

Comments
 (0)