Spaces:
Running
Running
slashlib
commited on
cmake : support for CPU BLAS build via Intel MKL (#2024)
Browse files- CMakeLists.txt +12 -0
- README.md +15 -0
CMakeLists.txt
CHANGED
|
@@ -82,6 +82,7 @@ else()
|
|
| 82 |
option(WHISPER_CUBLAS "whisper: support for CUDA (deprecated)" OFF)
|
| 83 |
option(WHISPER_HIPBLAS "whisper: support for hipBLAS" OFF)
|
| 84 |
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
|
|
|
|
| 85 |
option(WHISPER_SYCL "whisper: use SYCL" OFF)
|
| 86 |
option(WHISPER_SYCL_F16 "whisper: use 16 bit floats for sycl calculations" OFF)
|
| 87 |
endif()
|
|
@@ -296,6 +297,13 @@ if (WHISPER_BLAS)
|
|
| 296 |
endif ()
|
| 297 |
endif ()
|
| 298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
if (WHISPER_CUBLAS)
|
| 300 |
message(WARNING "WHISPER_CUBLAS is deprecated and will be removed in the future.\nUse WHISPER_CUDA instead")
|
| 301 |
set(WHISPER_CUDA ON)
|
|
@@ -630,6 +638,10 @@ if (WHISPER_OPENVINO)
|
|
| 630 |
target_link_libraries(${TARGET} PRIVATE whisper.openvino)
|
| 631 |
endif()
|
| 632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
if (MSVC)
|
| 634 |
target_link_libraries(${TARGET} PRIVATE ${WHISPER_EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
| 635 |
|
|
|
|
| 82 |
option(WHISPER_CUBLAS "whisper: support for CUDA (deprecated)" OFF)
|
| 83 |
option(WHISPER_HIPBLAS "whisper: support for hipBLAS" OFF)
|
| 84 |
option(WHISPER_CLBLAST "whisper: use CLBlast" OFF)
|
| 85 |
+
option(WHISPER_MKL "whisper: use Intel Math Kernel Library (MKL)" OFF)
|
| 86 |
option(WHISPER_SYCL "whisper: use SYCL" OFF)
|
| 87 |
option(WHISPER_SYCL_F16 "whisper: use 16 bit floats for sycl calculations" OFF)
|
| 88 |
endif()
|
|
|
|
| 297 |
endif ()
|
| 298 |
endif ()
|
| 299 |
|
| 300 |
+
if (WHISPER_MKL)
|
| 301 |
+
find_package(MKL CONFIG REQUIRED PATHS $ENV{MKLROOT})
|
| 302 |
+
message(STATUS "Imported oneMKL targets: ${MKL_IMPORTED_TARGETS}")
|
| 303 |
+
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_USE_OPENBLAS)
|
| 304 |
+
set(WHISPER_EXTRA_FLAGS ${WHISPER_EXTRA_FLAGS} -DGGML_BLAS_USE_MKL)
|
| 305 |
+
endif()
|
| 306 |
+
|
| 307 |
if (WHISPER_CUBLAS)
|
| 308 |
message(WARNING "WHISPER_CUBLAS is deprecated and will be removed in the future.\nUse WHISPER_CUDA instead")
|
| 309 |
set(WHISPER_CUDA ON)
|
|
|
|
| 638 |
target_link_libraries(${TARGET} PRIVATE whisper.openvino)
|
| 639 |
endif()
|
| 640 |
|
| 641 |
+
if (WHISPER_MKL)
|
| 642 |
+
target_link_libraries(${TARGET} PUBLIC MKL::MKL)
|
| 643 |
+
endif()
|
| 644 |
+
|
| 645 |
if (MSVC)
|
| 646 |
target_link_libraries(${TARGET} PRIVATE ${WHISPER_EXTRA_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
| 647 |
|
README.md
CHANGED
|
@@ -455,6 +455,21 @@ make clean
|
|
| 455 |
WHISPER_OPENBLAS=1 make -j
|
| 456 |
```
|
| 457 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
## Docker
|
| 459 |
|
| 460 |
### Prerequisites
|
|
|
|
| 455 |
WHISPER_OPENBLAS=1 make -j
|
| 456 |
```
|
| 457 |
|
| 458 |
+
## BLAS CPU support via Intel MKL
|
| 459 |
+
|
| 460 |
+
Encoder processing can be accelerated on the CPU via the BLAS compatible interface of Intel's Math Kernel Library.
|
| 461 |
+
First, make sure you have installed Intel's MKL runtime and development packages: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html
|
| 462 |
+
|
| 463 |
+
Now build `whisper.cpp` with Intel MKL BLAS support:
|
| 464 |
+
|
| 465 |
+
```
|
| 466 |
+
source /opt/intel/oneapi/setvars.sh
|
| 467 |
+
mkdir build
|
| 468 |
+
cd build
|
| 469 |
+
cmake -DWHISPER_MKL=ON ..
|
| 470 |
+
WHISPER_MKL=1 make -j
|
| 471 |
+
```
|
| 472 |
+
|
| 473 |
## Docker
|
| 474 |
|
| 475 |
### Prerequisites
|