From 2287e1d849f65a9046c247e75333b825fb1a4de7 Mon Sep 17 00:00:00 2001 From: Alexey Kharlamov Date: Sat, 6 May 2023 15:58:38 +0100 Subject: [PATCH 1/2] Build with any BLAS library --- CMakeLists.txt | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd2b0d0daa4..4da0188dcbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,9 +59,11 @@ if (APPLE) option(WHISPER_COREML "whisper: enable Core ML framework" OFF) option(WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF) else() - option(WHISPER_OPENBLAS "whisper: support for OpenBLAS" OFF) - option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF) - option(WHISPER_CLBLAST "whisper: use CLBlast" OFF) + option(WHISPER_BLAS "whisper: use BLAS libraries" OFF) + option(WHISPER_BLAS_VENDOR "whisper: BLAS library vendor" Generic) + option(WHISPER_OPENBLAS "whisper: prefer OpenBLAS" OFF) + option(WHISPER_CUBLAS "whisper: support for cuBLAS" OFF) + option(WHISPER_CLBLAST "whisper: use CLBlast" OFF) endif() option(WHISPER_PERF "whisper: enable perf timings" OFF) @@ -127,18 +129,28 @@ if (APPLE) endif() if (WHISPER_OPENBLAS) - find_library(OPENBLAS_LIB - NAMES openblas libopenblas - ) - if (OPENBLAS_LIB) - message(STATUS "OpenBLAS found") + set(WHISPER_BLAS_VENDOR "OpenBLAS") + set(WHISPER_BLAS ON) +endif() - set(WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} ${OPENBLAS_LIB}) +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 "OpenBLAS not found") + message(WARNING "BLAS library was not found") endif() -endif() +endif () if (WHISPER_CUBLAS) cmake_minimum_required(VERSION 3.17) @@ -147,7 +159,7 @@ if (WHISPER_CUBLAS) if (CUDAToolkit_FOUND) message(STATUS "cuBLAS found") - + set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc) enable_language(CUDA) set(GGML_CUDA_SOURCES ggml-cuda.cu ggml-cuda.h) From 9a5cc03301f2257efa6c0d5afd1ce79dbcb1aa84 Mon Sep 17 00:00:00 2001 From: Alexey Kharlamov Date: Sat, 20 May 2023 19:16:22 +0100 Subject: [PATCH 2/2] ci: Removed explicit CUDA nvcc path --- .gitignore | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 08aa2a85d65..23b3cd77623 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ extra/bench-gg.txt models/*.mlmodel models/*.mlmodelc models/*.mlpackage + +.idea/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4da0188dcbd..91404ad8707 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ if (WHISPER_CUBLAS) if (CUDAToolkit_FOUND) message(STATUS "cuBLAS found") - set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc) + enable_language(CUDA) set(GGML_CUDA_SOURCES ggml-cuda.cu ggml-cuda.h)