Skip to content

Commit a195bf8

Browse files
authored
cmake : enable OpenBLAS on Windows (ggml-org#1128)
Fixed the issue of not being able to find OpenBLAS on the Windows platform. Even though the name of the previously released binary file was whisper-blas-bin-x64.zip, BLAS was actually not enabled. After enabling, the inference speed can increase by 3-4 times.
1 parent ded17dc commit a195bf8

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

CMakeLists.txt

+27-16
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,33 @@ if (WHISPER_OPENBLAS)
136136
endif()
137137

138138
if (WHISPER_BLAS)
139-
set(BLA_STATIC 1)
140-
set(BLA_VENDOR ${WHISPER_BLAS_VENDOR})
141-
# set(BLA_PREFER_PKGCONFIG 1)
142-
set(BLA_SIZEOF_INTEGER 8)
143-
find_package(BLAS)
144-
145-
if(BLAS_FOUND)
146-
message(STATUS "BLAS compatible library found")
147-
message(STATUS "Libraries ${BLAS_LIBRARIES}")
148-
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
149-
150-
include_directories(${BLAS_INCLUDE_DIRS})
151-
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
152-
else()
153-
message(WARNING "BLAS library was not found")
154-
endif()
139+
if (WIN32)
140+
if(DEFINED ENV{OPENBLAS_PATH})
141+
set(BLAS_LIBRARIES $ENV{OPENBLAS_PATH}/lib/libopenblas.dll.a)
142+
message(STATUS "Libraries ${BLAS_LIBRARIES}")
143+
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
144+
include_directories($ENV{OPENBLAS_PATH}/include)
145+
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
146+
else ()
147+
message(WARNING "BLAS library was not found. Environment variable OPENBLAS_PATH not defined.")
148+
endif ()
149+
else ()
150+
set(BLA_STATIC 1)
151+
set(BLA_VENDOR ${WHISPER_BLAS_VENDOR})
152+
# set(BLA_PREFER_PKGCONFIG 1)
153+
set(BLA_SIZEOF_INTEGER 8)
154+
find_package(BLAS)
155+
156+
if(BLAS_FOUND)
157+
message(STATUS "BLAS compatible library found")
158+
message(STATUS "Libraries ${BLAS_LIBRARIES}")
159+
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
160+
include_directories(${BLAS_INCLUDE_DIRS})
161+
set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${BLAS_LIBRARIES})
162+
else()
163+
message(WARNING "BLAS library was not found")
164+
endif()
165+
endif ()
155166
endif ()
156167

157168
if (WHISPER_CUBLAS)

0 commit comments

Comments
 (0)