├── .gitignore ├── generate-checksums.ps1 ├── patches ├── fix-ggml-metal-install-source-dir.patch ├── disable-new-accelerate-api-macos-less-than-13-3.patch └── whispercpp-patches.patch ├── cmake └── FindCLBlast.cmake ├── README.md ├── setup_cuda.ps1 ├── LICENSE ├── .github └── workflows │ └── build.yml └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | release/ 3 | 4 | #vscode 5 | .vscode/ 6 | 7 | #vs 8 | .vs/ 9 | 10 | #mac 11 | .DS_Store 12 | 13 | *.tar.gz 14 | 15 | #built archives 16 | *.zip 17 | *.tgz 18 | *.xz 19 | 20 | CHECKSUMS.txt 21 | -------------------------------------------------------------------------------- /generate-checksums.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [string]$Path 3 | ) 4 | 5 | Get-ChildItem -Path $Path -Recurse -Include *.exe,*.deb,*.ddeb,*.pkg,*.tar.gz,*.tar.xz,*.zip | Foreach-Object { 6 | $name = $_.Name 7 | $hash = (Get-FileHash $name).Hash.ToLower() 8 | " ${name}: ${hash}" >> "$Path\CHECKSUMS.txt" 9 | } 10 | -------------------------------------------------------------------------------- /patches/fix-ggml-metal-install-source-dir.patch: -------------------------------------------------------------------------------- 1 | diff --git a/ggml/src/ggml-metal/CMakeLists.txt b/ggml/src/ggml-metal/CMakeLists.txt 2 | index 63418fe1..63e6aeb8 100644 3 | --- a/ggml/src/ggml-metal/CMakeLists.txt 4 | +++ b/ggml/src/ggml-metal/CMakeLists.txt 5 | @@ -109,7 +109,7 @@ endif() # GGML_METAL_EMBED_LIBRARY 6 | 7 | if (NOT GGML_METAL_EMBED_LIBRARY) 8 | install( 9 | - FILES src/ggml-metal/ggml-metal.metal 10 | + FILES ./ggml-metal.metal 11 | PERMISSIONS 12 | OWNER_READ 13 | OWNER_WRITE 14 | -------------------------------------------------------------------------------- /patches/disable-new-accelerate-api-macos-less-than-13-3.patch: -------------------------------------------------------------------------------- 1 | diff --git a/ggml/src/ggml-blas/CMakeLists.txt b/ggml/src/ggml-blas/CMakeLists.txt 2 | index 60ce4b1e..b6d2825d 100644 3 | --- a/ggml/src/ggml-blas/CMakeLists.txt 4 | +++ b/ggml/src/ggml-blas/CMakeLists.txt 5 | @@ -16,8 +16,14 @@ if (BLAS_FOUND) 6 | ) 7 | 8 | if (${GGML_BLAS_VENDOR} MATCHES "Apple") 9 | - add_compile_definitions(ACCELERATE_NEW_LAPACK) 10 | - add_compile_definitions(ACCELERATE_LAPACK_ILP64) 11 | + string(COMPARE GREATER_EQUAL ${CMAKE_OSX_DEPLOYMENT_TARGET} 13.3 HAS_NEW_LAPACK) 12 | + if(${HAS_NEW_LAPACK}) 13 | + message(STATUS "MacOS deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET} has new LAPACK interface") 14 | + add_compile_definitions(ACCELERATE_NEW_LAPACK) 15 | + add_compile_definitions(ACCELERATE_LAPACK_ILP64) 16 | + else() 17 | + message(STATUS "MacOS deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET} does not have new LAPACK interface") 18 | + endif() 19 | add_compile_definitions(GGML_BLAS_USE_ACCELERATE) 20 | elseif ("${BLAS_INCLUDE_DIRS}" STREQUAL "") 21 | # BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake. 22 | -------------------------------------------------------------------------------- /patches/whispercpp-patches.patch: -------------------------------------------------------------------------------- 1 | diff --git a/ggml/src/ggml-blas/CMakeLists.txt b/ggml/src/ggml-blas/CMakeLists.txt 2 | index 60ce4b1e..b6d2825d 100644 3 | --- a/ggml/src/ggml-blas/CMakeLists.txt 4 | +++ b/ggml/src/ggml-blas/CMakeLists.txt 5 | @@ -16,8 +16,14 @@ if (BLAS_FOUND) 6 | ) 7 | 8 | if (${GGML_BLAS_VENDOR} MATCHES "Apple") 9 | - add_compile_definitions(ACCELERATE_NEW_LAPACK) 10 | - add_compile_definitions(ACCELERATE_LAPACK_ILP64) 11 | + string(COMPARE GREATER_EQUAL ${CMAKE_OSX_DEPLOYMENT_TARGET} 13.3 HAS_NEW_LAPACK) 12 | + if(${HAS_NEW_LAPACK}) 13 | + message(STATUS "MacOS deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET} has new LAPACK interface") 14 | + add_compile_definitions(ACCELERATE_NEW_LAPACK) 15 | + add_compile_definitions(ACCELERATE_LAPACK_ILP64) 16 | + else() 17 | + message(STATUS "MacOS deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET} does not have new LAPACK interface") 18 | + endif() 19 | add_compile_definitions(GGML_BLAS_USE_ACCELERATE) 20 | elseif ("${BLAS_INCLUDE_DIRS}" STREQUAL "") 21 | # BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake. 22 | diff --git a/ggml/src/ggml-metal/CMakeLists.txt b/ggml/src/ggml-metal/CMakeLists.txt 23 | index 63418fe1..63e6aeb8 100644 24 | --- a/ggml/src/ggml-metal/CMakeLists.txt 25 | +++ b/ggml/src/ggml-metal/CMakeLists.txt 26 | @@ -109,7 +109,7 @@ endif() # GGML_METAL_EMBED_LIBRARY 27 | 28 | if (NOT GGML_METAL_EMBED_LIBRARY) 29 | install( 30 | - FILES src/ggml-metal/ggml-metal.metal 31 | + FILES ./ggml-metal.metal 32 | PERMISSIONS 33 | OWNER_READ 34 | OWNER_WRITE 35 | -------------------------------------------------------------------------------- /cmake/FindCLBlast.cmake: -------------------------------------------------------------------------------- 1 | # Assume the library is called libCLBlast.a and the headers are in 'include' 2 | find_path(CLBlast_INCLUDE_DIR NAMES clblast.h 3 | PATHS ${clblast_SOURCE_DIR}/include) 4 | 5 | find_library(CLBlast_LIBRARY NAMES clblast 6 | PATHS ${clblast_SOURCE_DIR}/lib) 7 | 8 | # find opencl sdk includes 9 | find_path(OPENCL_INCLUDE_DIR NAMES CL/opencl.h 10 | PATHS ${opencl_sdk_SOURCE_DIR}/include) 11 | 12 | # find opencl sdk libraries 13 | find_library(OPENCL_LIBRARY NAMES OpenCL 14 | PATHS ${opencl_sdk_SOURCE_DIR}/lib) 15 | 16 | include(FindPackageHandleStandardArgs) 17 | find_package_handle_standard_args(CLBlast DEFAULT_MSG 18 | CLBlast_LIBRARY CLBlast_INCLUDE_DIR) 19 | 20 | if(CLBlast_FOUND AND NOT TARGET clbast) 21 | add_library(clbast::clblast STATIC IMPORTED) 22 | set_target_properties(clbast::clblast PROPERTIES 23 | IMPORTED_LOCATION "${CLBlast_LIBRARY}" 24 | INTERFACE_INCLUDE_DIRECTORIES "${CLBlast_INCLUDE_DIR}") 25 | # add opencl library 26 | add_library(opencl STATIC IMPORTED) 27 | set_target_properties(opencl PROPERTIES 28 | IMPORTED_LOCATION "${OPENCL_LIBRARY}" 29 | INTERFACE_INCLUDE_DIRECTORIES "${OPENCL_INCLUDE_DIR}") 30 | 31 | # add clblast as an interface for clbast::clblast and opencl both 32 | add_library(clblast INTERFACE) 33 | target_link_libraries(clblast INTERFACE clbast::clblast opencl) 34 | 35 | # find the library dir and store in CLBlast_LIBRARY_DIR 36 | get_filename_component(CLBlast_LIBRARY_DIR ${CLBlast_LIBRARY} DIRECTORY) 37 | get_filename_component(OpenCL_LIBRARY_DIR ${OPENCL_LIBRARY} DIRECTORY) 38 | 39 | # Add to include directories 40 | include_directories(${CLBlast_INCLUDE_DIR} ${OPENCL_INCLUDE_DIR}) 41 | # add the link directories 42 | link_directories(${CLBlast_LIBRARY_DIR} ${OpenCL_LIBRARY_DIR}) 43 | endif() 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Whisper.cpp prebuilt binaries 2 | Whisper.cpp prebuilt binaries for static and dynamic linking 3 | 4 | ## Building on Windows 5 | 6 | You will need MSVS 2022 installed. 7 | 8 | Set up environment variables, e.g.: 9 | 10 | ```powershell 11 | > $env:BUILD_WITH_ACCEL="nvidia" 12 | > $env:CUDA_TOOLKIT_ROOT_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5" 13 | ``` 14 | 15 | Acceleration options: `generic`, `nvidia` and `amd` 16 | 17 | For `amd` make sure `$env:HIP_PATH` points to the HIP installation folder, e.g. where `$env:HIP_PATH\bin\clang.exe` would be located. See https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md#hip for more details 18 | 19 | The HIP installer can be downloaded from https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-Win10-Win11-For-HIP.exe. 20 | 21 | You'll also need `make` which is most easily obtained by [installing Chocolatey](https://docs.chocolatey.org/en-us/choco/setup/) and then running `choco install make` 22 | 23 | Run the build script: 24 | 25 | ```powershell 26 | > ./Build-Windows.ps1 -Version 0.0.11 27 | ``` 28 | 29 | ## Building on Mac OS 30 | 31 | Set the `MACOS_ARCH` env variable to `x86_64` or `arm64`: 32 | 33 | ```bash 34 | $ export MACOS_ARCH=x86_64 35 | ``` 36 | 37 | Set the `METAL_STD` env variable to `2.4` (for MacOS 12.0+), `3.0` (for MacOS 13.0+), `3.1` (for MacOS 14.0+), or `3.2` (for MacOS 15.0+) 38 | 39 | ```bash 40 | $ export METAL_STD=2.4 41 | ``` 42 | 43 | To disable CoreML support, set the `USE_COREML` env var to `off` 44 | 45 | ```bash 46 | $ export USE_COREML=off 47 | ``` 48 | 49 | Run the build script: 50 | 51 | ```bash 52 | $ ./build-macos.sh 0.0.11 53 | ``` 54 | 55 | ## Building on Linux 56 | 57 | Set up environment variables, e.g.: 58 | 59 | ```powershell 60 | > $env:BUILD_WITH_ACCEL="nvidia" 61 | > $env:CUDA_TOOLKIT_ROOT_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5" 62 | ``` 63 | 64 | Acceleration options: `generic`, `nvidia` and `amd` 65 | 66 | For `amd` install the ROCm SDK v6.4.2 67 | For `nvidia` install the CUDA SDK v12.8.0 68 | 69 | For all variants install the Vulkan and OpenCL SDKs, as well as OpenBLAS 70 | 71 | Run the build script: 72 | 73 | ```bash 74 | $ ./build-linux.sh 0.0.11 75 | ``` 76 | -------------------------------------------------------------------------------- /setup_cuda.ps1: -------------------------------------------------------------------------------- 1 | # From: https://github.com/thewh1teagle/vibe/blob/main/scripts/setup_cuda.ps1 2 | # Rendered here under the MIT License 3 | # Copyright (c) 2024 thewh1teagle 4 | 5 | $CUDA_VERSION_FULL = $env:INPUT_CUDA_VERSION # v12.5.0 or v11.8.0 6 | 7 | # Make sure CUDA_VERSION_FULL is set and valid, otherwise error. 8 | # Validate CUDA version, extracting components via regex 9 | $cuda_ver_matched = $CUDA_VERSION_FULL -match "^(?[1-9][0-9]*)\.(?[0-9]+)\.(?[0-9]+)$" 10 | if (-not $cuda_ver_matched) { 11 | Write-Output "Invalid CUDA version specified, .. required. '$CUDA_VERSION_FULL'." 12 | exit 1 13 | } 14 | $CUDA_MAJOR = $Matches.major 15 | $CUDA_MINOR = $Matches.minor 16 | $CUDA_PATCH = $Matches.patch 17 | 18 | Write-Output "Selected CUDA version: $CUDA_VERSION_FULL" 19 | 20 | $src = "cuda" 21 | $dst = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v$($CUDA_MAJOR).$($CUDA_MINOR)" 22 | $installer = "cuda.exe" 23 | 24 | $cudaVersions = @{ 25 | '12.8.1' = 'https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_572.61_windows.exe' 26 | '12.8.0' = 'https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda_12.8.0_571.96_windows.exe' 27 | '12.6.3' = 'https://developer.download.nvidia.com/compute/cuda/12.6.3/local_installers/cuda_12.6.3_561.17_windows.exe' 28 | '12.6.2' = 'https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.94_windows.exe' 29 | '12.6.1' = 'https://developer.download.nvidia.com/compute/cuda/12.6.1/local_installers/cuda_12.6.1_560.94_windows.exe' 30 | '12.6.0' = 'https://developer.download.nvidia.com/compute/cuda/12.6.0/local_installers/cuda_12.6.0_560.76_windows.exe' 31 | '12.5.1' = 'https://developer.download.nvidia.com/compute/cuda/12.5.1/local_installers/cuda_12.5.1_555.85_windows.exe' 32 | '12.5.0' = 'https://developer.download.nvidia.com/compute/cuda/12.5.0/local_installers/cuda_12.5.0_555.85_windows.exe' 33 | '12.4.1' = 'https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_551.78_windows.exe' 34 | '12.4.0' = 'https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_551.61_windows.exe' 35 | '12.3.2' = 'https://developer.download.nvidia.com/compute/cuda/12.3.2/local_installers/cuda_12.3.2_546.12_windows.exe' 36 | '12.3.1' = 'https://developer.download.nvidia.com/compute/cuda/12.3.1/local_installers/cuda_12.3.1_546.12_windows.exe' 37 | '12.3.0' = 'https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.84_windows.exe' 38 | '12.2.2' = 'https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_537.13_windows.exe' 39 | '12.2.1' = 'https://developer.download.nvidia.com/compute/cuda/12.2.1/local_installers/cuda_12.2.1_536.67_windows.exe' 40 | '12.2.0' = 'https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_536.25_windows.exe' 41 | '12.1.1' = 'https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_531.14_windows.exe' 42 | '12.1.0' = 'https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_531.14_windows.exe' 43 | '12.0.1' = 'https://developer.download.nvidia.com/compute/cuda/12.0.1/local_installers/cuda_12.0.1_528.33_windows.exe' 44 | '12.0.0' = 'https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda_12.0.0_527.41_windows.exe' 45 | '11.8.0' = 'https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_522.06_windows.exe' 46 | '11.7.1' = 'https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_516.94_windows.exe' 47 | '11.7.0' = 'https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_516.01_windows.exe' 48 | '11.6.2' = 'https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_511.65_windows.exe' 49 | '11.6.1' = 'https://developer.download.nvidia.com/compute/cuda/11.6.1/local_installers/cuda_11.6.1_511.65_windows.exe' 50 | '11.6.0' = 'https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_511.23_windows.exe' 51 | '11.5.2' = 'https://developer.download.nvidia.com/compute/cuda/11.5.2/local_installers/cuda_11.5.2_496.13_windows.exe' 52 | '11.5.1' = 'https://developer.download.nvidia.com/compute/cuda/11.5.1/local_installers/cuda_11.5.1_496.13_windows.exe' 53 | '11.5.0' = 'https://developer.download.nvidia.com/compute/cuda/11.5.0/local_installers/cuda_11.5.0_496.13_win10.exe' 54 | '11.4.4' = 'https://developer.download.nvidia.com/compute/cuda/11.4.4/local_installers/cuda_11.4.4_472.50_windows.exe' 55 | '11.4.3' = 'https://developer.download.nvidia.com/compute/cuda/11.4.3/local_installers/cuda_11.4.3_472.50_win10.exe' 56 | '11.4.2' = 'https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_471.41_win10.exe' 57 | '11.4.1' = 'https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda_11.4.1_471.41_win10.exe' 58 | '11.4.0' = 'https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_471.11_win10.exe' 59 | '11.3.1' = 'https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda_11.3.1_465.89_win10.exe' 60 | '11.3.0' = 'https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda_11.3.0_465.89_win10.exe' 61 | '11.2.2' = 'https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_461.33_win10.exe' 62 | '11.2.1' = 'https://developer.download.nvidia.com/compute/cuda/11.2.1/local_installers/cuda_11.2.1_461.09_win10.exe' 63 | '11.2.0' = 'https://developer.download.nvidia.com/compute/cuda/11.2.0/local_installers/cuda_11.2.0_460.89_win10.exe' 64 | '11.1.1' = 'https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_456.81_win10.exe' 65 | '11.0.3' = 'https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda_11.0.3_451.82_win10.exe' 66 | '11.0.2' = 'https://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda_11.0.2_451.48_win10.exe' 67 | '11.0.1' = 'https://developer.download.nvidia.com/compute/cuda/11.0.1/local_installers/cuda_11.0.1_451.22_win10.exe' 68 | '10.2.89' = 'https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_441.22_win10.exe' 69 | '10.1.243' = 'https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_426.00_win10.exe' 70 | '10.0.130' = 'https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_411.31_win10' 71 | '9.2.148' = 'https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers2/cuda_9.2.148_win10' 72 | '8.0.61' = 'https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_win10-exe' 73 | } 74 | 75 | if ($cudaVersions.ContainsKey($CUDA_VERSION_FULL)) { 76 | $cudaInstallerUrl = $cudaVersions[$CUDA_VERSION_FULL] 77 | Write-Output "CUDA version $CUDA_VERSION_FULL found. Downloading from $cudaInstallerUrl" 78 | # Add your download and installation logic here 79 | $downloadUrl = $cudaInstallerUrl 80 | } 81 | else { 82 | Write-Output "CUDA version $CUDA_VERSION_FULL not found." 83 | exit 1 84 | } 85 | 86 | # Download cuda 87 | Write-Output "Downloading CUDA from: $downloadUrl" 88 | if (-not (Test-Path -Path $installer)) { 89 | Write-Output "Downloading CUDA installer..." 90 | # If the file does not exist, download it 91 | & "C:\msys64\usr\bin\wget" $downloadUrl -O $installer -q 92 | } 93 | 94 | # Extract cuda 95 | if (-not (Test-Path -Path $src -Type Container)) { 96 | # Extract CUDA using 7-Zip 97 | Write-Output "Extracting CUDA using 7-Zip..." 98 | mkdir "$src" 99 | & 'C:\Program Files\7-Zip\7z' x $installer -o"$src" 100 | } 101 | 102 | # Create destination directory if it doesn't exist 103 | if (-Not (Test-Path -Path $dst)) { 104 | Write-Output "Creating destination directory: $dst" 105 | New-Item -Path $dst -ItemType Directory 106 | } 107 | 108 | # Get directories to process from the source path 109 | $directories = Get-ChildItem -Directory -Path $src 110 | $whitelist = @("CUDA_Toolkit_Release_Notes.txt", "DOCS", "EULA.txt", "LICENSE", "README", "version.json") 111 | 112 | foreach ($dir in $directories) { 113 | # Get all subdirectories and files in the current directory 114 | $items = Get-ChildItem -Path (Join-Path $src $dir.Name) 115 | 116 | foreach ($item in $items) { 117 | if ($item.PSIsContainer) { 118 | # If the item is a directory, copy its contents 119 | Write-Output "Copying contents of directory $($item.FullName) to $dst" 120 | Copy-Item -Path "$($item.FullName)\*" -Destination $dst -Recurse -Force 121 | } 122 | else { 123 | if ($whitelist -contains $item.Name) { 124 | Write-Output "Copying file $($item.FullName) to $dst" 125 | Copy-Item -Path $item.FullName -Destination $dst -Force 126 | } 127 | } 128 | } 129 | } 130 | 131 | # Add msbuild cuda extensions 132 | $msBuildExtensions = (Get-ChildItem "$src\visual_studio_integration\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions").fullname 133 | (Get-ChildItem 'C:\Program Files\Microsoft Visual Studio\2022\*\MSBuild\Microsoft\VC\*\BuildCustomizations').FullName | ForEach-Object { 134 | $destination = $_ 135 | $msBuildExtensions | ForEach-Object { 136 | $extension = $_ 137 | Copy-Item $extension -Destination $destination -Force 138 | Write-Output "Copied $extension to $destination" 139 | } 140 | } 141 | 142 | # Add to Github env 143 | Write-Output "Setting environment variables for GitHub Actions..." 144 | 145 | Write-Output "CUDA_PATH=$dst" 146 | Write-Output "CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)=$dst" 147 | Write-Output "CUDA_PATH_VX_Y=CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)" 148 | Write-Output "CUDA_VERSION=$CUDA_VERSION_FULL" 149 | 150 | Write-Output "CUDA_PATH=$dst" >> $env:GITHUB_ENV 151 | Write-Output "CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)=$dst" >> $env:GITHUB_ENV 152 | Write-Output "CUDA_PATH_VX_Y=CUDA_PATH_V$($CUDA_MAJOR)_$($CUDA_MINOR)" >> $env:GITHUB_ENV 153 | Write-Output "CudaToolkitDir=$dst" >> $env:GITHUB_ENV 154 | Write-Output "CMAKE_CUDA_COMPILER=$dst\bin\nvcc.exe" >> $env:GITHUB_ENV 155 | Write-Output "NVCC_APPEND_FLAGS=-allow-unsupported-compiler" >> $env:GITHUB_ENV 156 | 157 | Write-Output "CUDA_VERSION=$CUDA_VERSION_FULL" >> $env:GITHUB_ENV 158 | Write-Output "Setup completed." 159 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | tags: 8 | - "*" 9 | pull_request: 10 | branches: 11 | - "main" 12 | 13 | concurrency: 14 | group: "${{ github.workflow }}-${{ github.ref }}" 15 | cancel-in-progress: "${{ github.ref != 'refs/heads/main' }}" 16 | 17 | jobs: 18 | BuildMac: 19 | runs-on: "macos-14" 20 | 21 | strategy: 22 | matrix: 23 | config: 24 | - "Release" 25 | architecture: [x86_64, arm64] 26 | coreml: [on, off] 27 | metal-std: [embedded, 2.4, "3.0", 3.1, 3.2] 28 | # See support.apple.com/en-gb/102894 for compatibility info 29 | exclude: 30 | - architecture: arm64 31 | coreml: off 32 | - metal-std: "3.0" 33 | coreml: off 34 | - metal-std: 3.1 35 | coreml: off 36 | - metal-std: 3.2 37 | coreml: off 38 | 39 | defaults: 40 | run: 41 | shell: "bash" 42 | 43 | steps: 44 | - name: "Get version" 45 | run: | 46 | if [[ $GITHUB_REF =~ ^refs/tags/ ]] 47 | then version="${GITHUB_REF#refs/tags/}" 48 | else version=main 49 | fi 50 | printf "version=%s" "$version" > "$GITHUB_OUTPUT" 51 | id: "get-version" 52 | 53 | - uses: maxim-lobanov/setup-xcode@v1.6.0 54 | id: set-xcode-version 55 | with: 56 | xcode-version: 16.2 57 | 58 | - name: ccache 59 | uses: hendrikmuhs/ccache-action@v1.2 60 | with: 61 | key: ${{ github.job }}-MacOS-${{ matrix.architecture }} 62 | 63 | - name: "Install x86_64 homebrew" 64 | if: ${{ matrix.architecture == 'x86_64' }} 65 | run: | 66 | arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 67 | 68 | - name: "Install Vulkan SDK" 69 | run: | 70 | SDKVersion="1.4.328.1" 71 | SDKFileName="vulkansdk-macos-$SDKVersion.zip" 72 | curl --output /tmp/$SDKFileName https://sdk.lunarg.com/sdk/download/$SDKVersion/mac/$SDKFileName 73 | pushd /tmp 74 | unzip $SDKFileName 75 | vulkansdk-macos-$SDKVersion.app/Contents/MacOS/vulkansdk-macOS-$SDKVersion --accept-licenses --default-answer --confirm-command install 76 | pushd ~/VulkanSDK/$SDKVersion 77 | sudo python3 install_vulkan.py 78 | popd 79 | popd 80 | 81 | - name: "Checkout" 82 | uses: "actions/checkout@v4" 83 | 84 | - name: "Run build-macos.sh" 85 | run: "./build-macos.sh ${{ steps.get-version.outputs.version }}" 86 | env: 87 | MACOS_ARCH: ${{ matrix.architecture }} 88 | METAL_STD: ${{ matrix.metal-std }} 89 | USE_COREML: ${{ matrix.coreml }} 90 | 91 | - name: "Upload artifact" 92 | uses: "actions/upload-artifact@v4" 93 | with: 94 | name: ${{ matrix.coreml == 'on' && format('whispercpp-macos-{0}-metal{1}', matrix.architecture, matrix.metal-std) || format('whispercpp-macos-{0}-metal{1}-no-coreml', matrix.architecture, matrix.metal-std) }} 95 | path: "*.tar.gz" 96 | 97 | BuildLinux: 98 | runs-on: "ubuntu-22.04" 99 | 100 | strategy: 101 | matrix: 102 | config: 103 | - "Release" 104 | accel: [generic, nvidia, amd] 105 | 106 | defaults: 107 | run: 108 | shell: "bash" 109 | 110 | steps: 111 | - name: "Get version" 112 | run: | 113 | if [[ $GITHUB_REF =~ ^refs/tags/ ]] 114 | then version="${GITHUB_REF#refs/tags/}" 115 | else version=main 116 | fi 117 | printf "version=%s" "$version" > "$GITHUB_OUTPUT" 118 | id: "get-version" 119 | 120 | - name: Free Disk Space (Ubuntu) 121 | uses: jlumbroso/free-disk-space@main 122 | with: 123 | # this might remove tools that are actually needed, 124 | # if set to "true" but frees about 6 GB 125 | tool-cache: false 126 | # Needed to prevent running out of memory 127 | swap-storage: false 128 | 129 | android: true 130 | dotnet: true 131 | haskell: true 132 | large-packages: true 133 | docker-images: true 134 | 135 | - name: "Checkout" 136 | uses: "actions/checkout@v4" 137 | 138 | - name: "Install OpenBLAS and OpenCL" 139 | run: | 140 | sudo apt update 141 | sudo apt install libopenblas-dev libopenblas-openmp-dev nvidia-opencl-dev ocl-icd-opencl-dev opencl-headers 142 | 143 | - name: "Install Vulkan SDK" 144 | run: | 145 | sudo apt install -y wget 146 | wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc 147 | sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list 148 | sudo apt update 149 | sudo apt install vulkan-sdk 150 | 151 | # - name: "Install oneAPI (SYCL) toolkit" 152 | # run: | 153 | # # download the key to system keyring 154 | # wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ 155 | # | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null 156 | # # add signed entry to apt sources and configure the APT client to use Intel repository: 157 | # echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/ 158 | # oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list 159 | # sudo apt update 160 | # sudo apt install intel-basekit 161 | # # Probably don't need these 162 | # # sudo apt install intel-hpckit intel-renderkit 163 | 164 | - name: "Install CUDA toolkit" 165 | if: ${{ matrix.accel == 'nvidia' }} 166 | run: | 167 | wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb 168 | sudo dpkg -i cuda-keyring_1.1-1_all.deb 169 | sudo apt update 170 | sudo apt -y install cuda-toolkit-12-8 171 | export PATH=/usr/local/cuda-12.8/bin${PATH:+:${PATH}} 172 | export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 173 | 174 | - name: "Install AMD hip SDK v6.4.2" 175 | if: ${{ matrix.accel == 'amd' }} 176 | run: | 177 | wget https://repo.radeon.com/amdgpu-install/6.4.2/ubuntu/jammy/amdgpu-install_6.4.60402-1_all.deb 178 | sudo apt install ./amdgpu-install_6.4.60402-1_all.deb 179 | sudo apt update 180 | sudo apt install python3-setuptools python3-wheel 181 | sudo usermod -a -G render,video $LOGNAME # Add the current user to the render and video groups 182 | sudo apt install rocm 183 | sudo apt update && sudo apt install hipblas 184 | 185 | - name: "Run build-linux.sh" 186 | run: "chmod +x build-linux.sh && ./build-linux.sh ${{ matrix.config }} ${{ steps.get-version.outputs.version }}" 187 | env: 188 | BUILD_WITH_ACCEL: ${{ matrix.accel }} 189 | LINUX_ARCH: "x86_64" 190 | 191 | - uses: "actions/upload-artifact@v4" 192 | with: 193 | name: "whispercpp-linux-${{ matrix.config }}-${{ matrix.accel }}" 194 | path: "*.tar.gz" 195 | 196 | BuildWindows: 197 | runs-on: "windows-2022" 198 | 199 | strategy: 200 | matrix: 201 | config: 202 | - "Release" 203 | accel: [generic, nvidia, amd] 204 | 205 | steps: 206 | - name: "Get version" 207 | shell: bash 208 | run: | 209 | if [[ $GITHUB_REF =~ ^refs/tags/ ]] 210 | then version="${GITHUB_REF#refs/tags/}" 211 | else version=main 212 | fi 213 | printf "version=%s" "$version" > "$GITHUB_OUTPUT" 214 | id: "get-version" 215 | 216 | - name: "Checkout" 217 | uses: "actions/checkout@v4" 218 | 219 | - name: ccache 220 | uses: hendrikmuhs/ccache-action@v1.2 221 | with: 222 | key: ${{ github.job }}-Windows-${{ matrix.accel }} 223 | 224 | # - name: Install CUDA Toolkit 225 | # if: ${{ matrix.accel == 'cuda' }} 226 | # id: cuda-toolkit 227 | # uses: Jimver/cuda-toolkit@v0.2.21 228 | # with: 229 | # cuda: '12.5.1' 230 | # sub-packages: '["cudart", "nvcc", "cublas", "cublas_dev", "visual_studio_integration"]' 231 | # method: 'network' 232 | - name: Setup CUDA Toolkit 233 | if: ${{ matrix.accel == 'nvidia' }} 234 | id: cuda-toolkit 235 | shell: pwsh 236 | run: ./setup_cuda.ps1 237 | env: 238 | INPUT_CUDA_VERSION: '12.8.1' 239 | 240 | - name: Set CUDA_TOOLKIT_ROOT_DIR if CUDA is installed 241 | if: ${{ matrix.accel == 'nvidia' }} 242 | run: | 243 | "CUDA_TOOLKIT_ROOT_DIR=$env:CUDA_PATH" >> $env:GITHUB_ENV 244 | 245 | - name: Install AMD hip SDK v6.4.2 246 | id: depends-hipblas 247 | if: ${{ matrix.accel == 'amd' }} 248 | run: | 249 | $ErrorActionPreference = "Stop" 250 | write-host "Downloading AMD HIP SDK Installer" 251 | Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-25.Q3-Win10-Win11-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe" 252 | write-host "Installing AMD HIP SDK" 253 | Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait 254 | write-host "Completed AMD HIP SDK installation" 255 | 256 | - name: Verify ROCm 257 | id: verify-hipblas 258 | if: ${{ matrix.accel == 'amd' }} 259 | run: | 260 | & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version 261 | 262 | - name: Prepare hipBLAS environment 263 | id: prepare-hipblas 264 | if: ${{ matrix.accel == 'amd' }} 265 | run: | 266 | "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV 267 | 268 | - name: "Install Vulkan SDK (1.4.328.1)" 269 | run: | 270 | $ErrorActionPreference = "Stop" 271 | $SDKVersion = "1.4.328.1" 272 | $SDKFileName = "vulkansdk-windows-X64-${SDKVersion}.exe" 273 | write-host "Downloading Vulkan SDK" 274 | Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.4.328.1/windows/$SDKFileName" -OutFile "${env:RUNNER_TEMP}\$SDKFileName" 275 | write-host "Installing Vulkan SDK" 276 | Start-Process "${env:RUNNER_TEMP}\$SDKFileName" -ArgumentList '--accept-licenses --default-answer --confirm-command install' -NoNewWindow -Wait 277 | write-host "Completed Vulkan SDK installation" 278 | 279 | - name: "Run Build-Windows.ps1" 280 | run: "./Build-Windows.ps1 -Version ${{ steps.get-version.outputs.version }}" 281 | env: 282 | BUILD_WITH_ACCEL: ${{ matrix.accel }} 283 | 284 | - uses: "actions/upload-artifact@v4" 285 | with: 286 | name: "whispercpp-windows-${{ matrix.accel }}" 287 | path: "*.zip" 288 | 289 | Release: 290 | runs-on: "ubuntu-22.04" 291 | if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') 292 | 293 | needs: 294 | - "BuildMac" 295 | - "BuildLinux" 296 | - "BuildWindows" 297 | 298 | permissions: 299 | contents: "write" 300 | 301 | defaults: 302 | run: 303 | shell: "bash" 304 | 305 | steps: 306 | - name: "Get version" 307 | run: | 308 | if [[ $GITHUB_REF =~ ^refs/tags/ ]] 309 | then version="${GITHUB_REF#refs/tags/}" 310 | else version=main 311 | fi 312 | printf "version=%s" "$version" > "$GITHUB_OUTPUT" 313 | id: "get-version" 314 | 315 | - name: "Download build artifacts" 316 | uses: "actions/download-artifact@v4" 317 | 318 | - name: "Create Release" 319 | uses: "softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5" 320 | with: 321 | draft: true 322 | tag_name: "${{ steps.get-version.outputs.version }}" 323 | name: "${{ steps.get-version.outputs.version }}" 324 | files: | 325 | ${{ github.workspace }}/**/*.tar.gz 326 | ${{ github.workspace }}/**/*.zip 327 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | 3 | project(Whispercpp_prebuilt) 4 | 5 | include(ExternalProject) 6 | include(FetchContent) 7 | 8 | option(WHISPERCPP_NVIDIA "Build Whisper with CUDA support" OFF) 9 | option(WHISPERCPP_AMD "Build Whisper with hipBLAS support" OFF) 10 | 11 | set(CMAKE_OSX_ARCHITECTURES_ "$ENV{MACOS_ARCH}") 12 | 13 | set(Whispercpp_Build_GIT_TAG "v1.8.2") 14 | 15 | if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL 16 | RelWithDebInfo) 17 | set(Whispercpp_BUILD_TYPE RelWithDebInfo) 18 | else() 19 | set(Whispercpp_BUILD_TYPE Debug) 20 | endif() 21 | 22 | if(WHISPERCPP_AMD) 23 | # List supported ROCm GPU targets in ROCm 6.4.2, and also some unsupported ones that might work 24 | # See https://rocm.docs.amd.com/en/latest/compatibility/compatibility-matrix.html and https://rocm.docs.amd.com/en/docs-6.4.2/reference/gpu-arch-specs.html 25 | # gfx950 is supported in 7.1.0 but not 6.4.2 that we're using 26 | list(APPEND SUPPORTED_AMDGPU_TARGETS gfx908 gfx90a gfx942 gfx1030 gfx1100 gfx1200 gfx1201) 27 | list(APPEND UNSUPPORTED_AMDGPU_TARGETS gfx803 gfx900 gfx906 gfx950 gfx1010 gfx1011 gfx1012 gfx1031 gfx1032 gfx1101 gfx1102 gfx1150 gfx1151 gfx1152) 28 | list(APPEND AMDGPU_TARGETS ${SUPPORTED_AMDGPU_TARGETS} ${UNSUPPORTED_AMDGPU_TARGETS}) 29 | list(JOIN AMDGPU_TARGETS ";" AMDGPU_TARGETS_STRING) 30 | message(STATUS "AMD GPU TARGETS: ${AMDGPU_TARGETS_STRING}") 31 | foreach(TARGET ${AMDGPU_TARGETS}) 32 | list(APPEND AMDGPU_TARGET_FLAGS "--offload-arch=${TARGET}") 33 | endforeach(TARGET ${AMDGPU_TARGETS}) 34 | list(JOIN AMDGPU_TARGET_FLAGS " " AMDGPU_TARGET_FLAGS_STRING) 35 | endif() 36 | 37 | if(UNIX AND NOT APPLE) 38 | # On linux add the `-fPIC` flag to the compiler 39 | set(WHISPER_EXTRA_CXX_FLAGS "-fPIC") 40 | 41 | list( 42 | APPEND 43 | WHISPER_ADDITIONAL_CMAKE_ARGS 44 | # OpenBLAS 45 | -DGGML_BLAS=ON 46 | -DGGML_BLAS_VENDOR=OpenBLAS 47 | # Vulkan 48 | -DGGML_VULKAN=ON 49 | # OpenCL 50 | -DGGML_OPENCL=ON 51 | -DGGML_OPENCL_EMBED_KERNELS=ON 52 | -DGGML_OPENCL_USE_ADRENO_KERNELS=OFF 53 | # SYCL -DGGML_SYCL=ON Dynamic backends 54 | -DGGML_NATIVE=OFF 55 | -DGGML_BACKEND_DL=ON 56 | -DGGML_CPU_ALL_VARIANTS=ON) 57 | set(CMAKE_PARALLEL --parallel) 58 | 59 | if(WHISPERCPP_NVIDIA) 60 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_CUDA=ON 61 | -DCMAKE_CUDA_ARCHITECTURES=all 62 | -DCMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}) 63 | # -DGGML_SYCL_TARGET=NVIDIA) 64 | set(CMAKE_PARALLEL "--parallel 3") 65 | elseif(WHISPERCPP_AMD) 66 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_C_COMPILER=hipcc 67 | -DCMAKE_CXX_COMPILER=hipcc -DGGML_HIP=ON) 68 | set(WHISPER_EXTRA_CXX_FLAGS "-fPIC -g --no-warnings ${AMDGPU_TARGET_FLAGS_STRING}") 69 | # -DGGML_SYCL_TARGET=AMD) 70 | endif() 71 | endif() 72 | 73 | if(APPLE) 74 | # check the "MACOS_ARCH" env var to figure out if this is x86_64 or arm64 75 | if(NOT DEFINED ENV{MACOS_ARCH}) 76 | message( 77 | FATAL_ERROR 78 | "The MACOS_ARCH environment variable is not set. Please set it to either `x86_64` or `arm64`" 79 | ) 80 | endif(NOT DEFINED ENV{MACOS_ARCH}) 81 | 82 | # cmake-format: off 83 | # note: use 'ios-metal1.0' for 'Metal 1.0 (iOS)' standard 84 | # note: use 'ios-metal1.1' for 'Metal 1.1 (iOS)' standard 85 | # note: use 'ios-metal1.2' for 'Metal 1.2 (iOS)' standard 86 | # note: use 'ios-metal2.0' for 'Metal 2.0 (iOS)' standard 87 | # note: use 'ios-metal2.1' for 'Metal 2.1 (iOS)' standard 88 | # note: use 'ios-metal2.2' for 'Metal 2.2 (iOS)' standard 89 | # note: use 'ios-metal2.3' for 'Metal 2.3 (iOS)' standard 90 | # note: use 'ios-metal2.4' for 'Metal 2.4 (iOS)' standard 91 | # note: use 'macos-metal1.0' or 'osx-metal1.0' for 'Metal 1.0 (macOS)' standard 92 | # note: use 'macos-metal1.1' or 'osx-metal1.1' for 'Metal 1.1 (macOS)' standard 93 | # note: use 'macos-metal1.2' or 'osx-metal1.2' for 'Metal 1.2 (macOS)' standard 94 | # note: use 'macos-metal2.0' or 'osx-metal2.0' for 'Metal 2.0 (macOS)' standard 95 | # note: use 'macos-metal2.1' for 'Metal 2.1 (macOS)' standard 96 | # note: use 'macos-metal2.2' for 'Metal 2.2 (macOS)' standard 97 | # note: use 'macos-metal2.3' for 'Metal 2.3 (macOS)' standard 98 | # note: use 'macos-metal2.4' for 'Metal 2.4 (macOS)' standard 99 | # note: use 'metal3.0' for 'Metal 3.0' standard 100 | # note: use 'metal3.1' for 'Metal 3.1' standard 101 | # note: use 'metal3.2' for 'Metal 3.2' standard 102 | # cmake-format: on 103 | 104 | # Presumably need newer XCode and/or a Tahoe (26) runner to get standard v4 105 | 106 | option(METAL_STD "Which Metal version to target" macos-metal2.4) 107 | option(USE_COREML "Enable CoreML support" ON) 108 | 109 | if(DEFINED ENV{METAL_STD}) 110 | if($ENV{METAL_STD} STREQUAL 2.4) 111 | set(METAL_STD "macos-metal$ENV{METAL_STD}") 112 | set(EMBED_METAL OFF) 113 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0) 114 | elseif($ENV{METAL_STD} STREQUAL 3.0) 115 | set(METAL_STD "metal$ENV{METAL_STD}") 116 | set(EMBED_METAL OFF) 117 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_OSX_DEPLOYMENT_TARGET=13.3) 118 | elseif($ENV{METAL_STD} STREQUAL 3.1) 119 | set(METAL_STD "metal$ENV{METAL_STD}") 120 | set(EMBED_METAL OFF) 121 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0) 122 | elseif($ENV{METAL_STD} STREQUAL 3.2) 123 | set(METAL_STD "metal$ENV{METAL_STD}") 124 | set(EMBED_METAL OFF) 125 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0) 126 | elseif($ENV{METAL_STD} STREQUAL embedded) 127 | set(EMBED_METAL ON) 128 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0) 129 | else() 130 | message(FATAL_ERROR "Unsupported Metal standard $ENV{METAL_STD}") 131 | endif() 132 | endif() 133 | 134 | if(DEFINED ENV{USE_COREML}) 135 | set(USE_COREML $ENV{USE_COREML}) 136 | endif() 137 | 138 | list( 139 | APPEND 140 | WHISPER_ADDITIONAL_CMAKE_ARGS 141 | -DCMAKE_PREFIX_PATH=$ENV{OPENMP_PREFIX} 142 | -DGGML_VULKAN=ON 143 | -DGGML_METAL=ON 144 | -DGGML_METAL_MACOSX_VERSION_MIN=12.0 145 | -DGGML_METAL_STD=${METAL_STD} 146 | -DGGML_METAL_EMBED_LIBRARY=OFF 147 | -DGGML_NATIVE=OFF 148 | -DGGML_BACKEND_DL=ON) 149 | 150 | if(${EMBED_METAL}) 151 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_METAL_EMBED_LIBRARY=ON) 152 | else() 153 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_METAL_EMBED_LIBRARY=OFF -DGGML_METAL_STD=${METAL_STD}) 154 | endif() 155 | 156 | if(${USE_COREML}) 157 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DWHISPER_COREML=ON 158 | -DWHISPER_COREML_ALLOW_FALLBACK=ON) 159 | endif() 160 | 161 | set(WHISPER_EXTRA_CXX_FLAGS 162 | "-Wno-shorten-64-to-32 -Wno-unused-parameter -Wno-unused-function -Wno-unguarded-availability-new" 163 | ) 164 | set(CMAKE_PARALLEL --parallel) 165 | 166 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_CPU_ALL_VARIANTS=ON) 167 | endif() 168 | 169 | if(WIN32) 170 | if(NOT WHISPERCPP_AMD) 171 | add_compile_options("$<$>:/Zi>") 172 | add_link_options("$<$>/DEBUG">) 173 | add_link_options("$<$>/OPT:REF">) 174 | add_link_options("$<$>/OPT:ICF">) 175 | endif() 176 | 177 | # Build with OpenBLAS for all configurations 178 | set(OpenBLAS_URL 179 | "https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.26/OpenBLAS-0.3.26-x64.zip" 180 | ) 181 | set(OpenBLAS_SHA256 182 | "859C510A962A30EF1B01AA93CDE26FDB5FB1050F94AD5AB2802EBA3731935E06") 183 | FetchContent_Declare( 184 | OpenBLAS 185 | URL ${OpenBLAS_URL} 186 | URL_HASH SHA256=${OpenBLAS_SHA256} 187 | DOWNLOAD_EXTRACT_TIMESTAMP true) 188 | FetchContent_MakeAvailable(OpenBLAS) 189 | set(OpenBLAS_DIR ${openblas_SOURCE_DIR}) 190 | message(STATUS "OpenBLAS_DIR: ${OpenBLAS_DIR}") 191 | set(WHISPER_ADDITIONAL_ENV "OPENBLAS_PATH=${openblas_SOURCE_DIR}") 192 | list( 193 | APPEND 194 | WHISPER_ADDITIONAL_CMAKE_ARGS 195 | -DGGML_BLAS=ON 196 | -DGGML_BLAS_VENDOR=OpenBLAS 197 | -DBLAS_LIBRARIES=${OpenBLAS_DIR}/lib/libopenblas.lib 198 | -DBLAS_INCLUDE_DIRS=${OpenBLAS_DIR}/include) 199 | set(WHISPER_CMAKE_GENERATOR ${CMAKE_GENERATOR}) 200 | 201 | if(NOT DEFINED ENV{VULKAN_SDK_PATH}) 202 | message( 203 | FATAL_ERROR 204 | "VULKAN_SDK_PATH is not set. Please set it to the root directory of your VulkanSDK installation, e.g. `C:/VulkanSDK/1.3.296.0`" 205 | ) 206 | endif() 207 | 208 | # Build with VULKAN 209 | list(APPEND WHISPER_ADDITIONAL_ENV "VULKAN_SDK=$ENV{VULKAN_SDK_PATH}") 210 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_VULKAN=ON) 211 | 212 | if(WHISPERCPP_NVIDIA) 213 | # Build with CUDA 214 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_CUDA=ON 215 | -DCMAKE_CUDA_ARCHITECTURES=all) 216 | elseif(WHISPERCPP_AMD) 217 | # Build with hipBLAS 218 | if(NOT DEFINED ENV{HIP_PATH}) 219 | message( 220 | FATAL_ERROR 221 | "HIP_PATH is not set. Please set it to the root directory of your HIP installation, e.g. `C:/Program Files/ROCm`" 222 | ) 223 | endif(NOT DEFINED ENV{HIP_PATH}) 224 | 225 | set(WHISPER_EXTRA_CXX_FLAGS "-g --no-warnings ${AMDGPU_TARGET_FLAGS_STRING}") 226 | cmake_path(SET HIP_PATH_STR NORMALIZE "$ENV{HIP_PATH}") 227 | list(APPEND WHISPER_ADDITIONAL_ENV "CMAKE_PREFIX_PATH=${HIP_PATH_STR}") 228 | list(APPEND WHISPER_ADDITIONAL_CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 229 | -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DGGML_HIP=ON) 230 | endif() 231 | 232 | ExternalProject_Add( 233 | Whispercpp_Build 234 | DOWNLOAD_EXTRACT_TIMESTAMP true 235 | GIT_REPOSITORY https://github.com/ggerganov/whisper.cpp.git 236 | GIT_TAG ${Whispercpp_Build_GIT_TAG} 237 | BUILD_COMMAND ${CMAKE_COMMAND} --build --parallel --config 238 | ${Whispercpp_BUILD_TYPE} --verbose 239 | BUILD_BYPRODUCTS 240 | /lib/static/${CMAKE_STATIC_LIBRARY_PREFIX}whisper${CMAKE_STATIC_LIBRARY_SUFFIX} 241 | /bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX} 242 | /bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper.pdb 243 | /lib/${CMAKE_IMPORT_LIBRARY_PREFIX}whisper${CMAKE_IMPORT_LIBRARY_SUFFIX} 244 | CMAKE_GENERATOR ${CMAKE_GENERATOR} 245 | INSTALL_COMMAND ${CMAKE_COMMAND} --install --config 246 | ${Whispercpp_BUILD_TYPE} 247 | CMAKE_CACHE_ARGS ${WHISPER_ADDITIONAL_CMAKE_CACHE_ARGS} 248 | CONFIGURE_COMMAND 249 | ${CMAKE_COMMAND} -E env ${WHISPER_ADDITIONAL_ENV} ${CMAKE_COMMAND} 250 | -B -G ${WHISPER_CMAKE_GENERATOR} 251 | -DCMAKE_INSTALL_PREFIX= 252 | -DCMAKE_BUILD_TYPE=${Whispercpp_BUILD_TYPE} 253 | -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} 254 | -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} 255 | -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DBUILD_SHARED_LIBS=ON 256 | -DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF 257 | -DWHISPER_BUILD_SERVER=OFF -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON 258 | -DGGML_CPU_ALL_VARIANTS=ON -DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/cmake 259 | ${WHISPER_ADDITIONAL_CMAKE_ARGS}) 260 | else() 261 | # On Linux and MacOS build a shared Whisper library 262 | ExternalProject_Add( 263 | Whispercpp_Build 264 | DOWNLOAD_EXTRACT_TIMESTAMP true 265 | GIT_REPOSITORY https://github.com/ggerganov/whisper.cpp.git 266 | GIT_TAG ${Whispercpp_Build_GIT_TAG} 267 | PATCH_COMMAND 268 | git apply 269 | ${CMAKE_SOURCE_DIR}/patches/whispercpp-patches.patch 270 | BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_PARALLEL} 271 | --config ${Whispercpp_BUILD_TYPE} --verbose 272 | BUILD_BYPRODUCTS 273 | /lib/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX} 274 | CMAKE_GENERATOR ${CMAKE_GENERATOR} 275 | INSTALL_COMMAND ${CMAKE_COMMAND} --install --config 276 | ${Whispercpp_BUILD_TYPE} 277 | CMAKE_CACHE_ARGS ${WHISPER_ADDITIONAL_CMAKE_CACHE_ARGS} 278 | CONFIGURE_COMMAND 279 | ${CMAKE_COMMAND} -E env ${WHISPER_ADDITIONAL_ENV} ${CMAKE_COMMAND} 280 | -B -G ${CMAKE_GENERATOR} 281 | -DCMAKE_INSTALL_PREFIX= 282 | -DCMAKE_BUILD_TYPE=${Whispercpp_BUILD_TYPE} 283 | -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} 284 | -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} 285 | -DCMAKE_CXX_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} 286 | -DCMAKE_C_FLAGS=${WHISPER_EXTRA_CXX_FLAGS} -DBUILD_SHARED_LIBS=ON 287 | -DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF 288 | -DWHISPER_BUILD_SERVER=OFF ${WHISPER_ADDITIONAL_CMAKE_ARGS}) 289 | endif(WIN32) 290 | 291 | ExternalProject_Get_Property(Whispercpp_Build SOURCE_DIR) 292 | ExternalProject_Get_Property(Whispercpp_Build INSTALL_DIR) 293 | ExternalProject_Get_Property(Whispercpp_Build BINARY_DIR) 294 | 295 | # add the Whisper library to the link line 296 | if(WIN32) 297 | # copy lib/ include/ and bin/ from ${INSTALL_DIR} to the release directory in 298 | # the root of the project 299 | install(DIRECTORY ${INSTALL_DIR}/lib DESTINATION ${CMAKE_SOURCE_DIR}/release) 300 | install(DIRECTORY ${INSTALL_DIR}/include 301 | DESTINATION ${CMAKE_SOURCE_DIR}/release) 302 | install(DIRECTORY ${INSTALL_DIR}/bin DESTINATION ${CMAKE_SOURCE_DIR}/release) 303 | install( 304 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml.pdb 305 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 306 | OPTIONAL) 307 | install( 308 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-base.pdb 309 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 310 | OPTIONAL) 311 | install( 312 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-blas.pdb 313 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 314 | OPTIONAL) 315 | install( 316 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/whisper.pdb 317 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 318 | OPTIONAL) 319 | install( 320 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu.pdb 321 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 322 | OPTIONAL) 323 | install( 324 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-alderlake.pdb 325 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 326 | OPTIONAL) 327 | install( 328 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-haswell.pdb 329 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 330 | OPTIONAL) 331 | install( 332 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-icelake.pdb 333 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 334 | OPTIONAL) 335 | install( 336 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-sandybridge.pdb 337 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 338 | OPTIONAL) 339 | install( 340 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-skylakex.pdb 341 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 342 | OPTIONAL) 343 | install( 344 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-sse42.pdb 345 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 346 | OPTIONAL) 347 | install( 348 | FILES ${BINARY_DIR}/bin/${Whispercpp_BUILD_TYPE}/ggml-cpu-x64.pdb 349 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin 350 | OPTIONAL) 351 | 352 | if(WHISPERCPP_AMD) 353 | message(STATUS "Setup HIP DLLs installation") 354 | set(HIPBLAS_DLLS 355 | "${HIP_PATH_STR}/bin/hipblas.dll" "${HIP_PATH_STR}/bin/rocblas.dll" 356 | "${HIP_PATH_STR}/bin/amdhip64_6.dll" 357 | "${HIP_PATH_STR}/bin/amd_comgr_2.dll") 358 | install(FILES ${HIPBLAS_DLLS} DESTINATION ${CMAKE_SOURCE_DIR}/release/bin) 359 | elseif(WHISPERCPP_NVIDIA) 360 | # Check that CUDA_TOOLKIT_ROOT_DIR is set 361 | if(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) 362 | message( 363 | FATAL_ERROR 364 | "CUDA_TOOLKIT_ROOT_DIR is not set. Please set it to the root directory of your CUDA " 365 | "installation, e.g. `C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4`" 366 | ) 367 | endif(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR) 368 | 369 | # normalize CUDA path with file(TO_CMAKE_PATH) 370 | file(TO_CMAKE_PATH ${CUDA_TOOLKIT_ROOT_DIR} CUDA_TOOLKIT_ROOT_DIR) 371 | 372 | # find the CUDA DLLs for cuBLAS in the bin directory of the CUDA 373 | # installation e.g. cublas64_NN.dll 374 | file(GLOB CUBLAS_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublas64_*.dll") 375 | 376 | # find cublasLt DLL, e.g. cublasLt64_11.dll 377 | file(GLOB CUBLASLT_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cublasLt64_*.dll") 378 | 379 | # find cudart DLL, e.g. cudart64_110.dll 380 | file(GLOB CUDART_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/cudart64_*.dll") 381 | 382 | # if any of the files cannot be found, abort 383 | if(NOT CUBLAS_DLLS 384 | OR NOT CUBLASLT_DLLS 385 | OR NOT CUDART_DLLS) 386 | message( 387 | FATAL_ERROR 388 | "Could not find cuBLAS, cuBLASLt or cuDART DLLs in ${CUDA_TOOLKIT_ROOT_DIR}/bin" 389 | ) 390 | endif() 391 | 392 | # copy the DLLs to the OBS plugin directory 393 | install(FILES ${CUBLAS_DLLS} ${CUBLASLT_DLLS} ${CUDART_DLLS} 394 | DESTINATION ${CMAKE_SOURCE_DIR}/release/bin) 395 | endif() 396 | 397 | message(STATUS "Install OpenBLAS DLLs") 398 | 399 | # add openblas to the link line 400 | install(DIRECTORY ${OpenBLAS_DIR}/lib DESTINATION ${CMAKE_SOURCE_DIR}/release) 401 | install(DIRECTORY ${OpenBLAS_DIR}/include 402 | DESTINATION ${CMAKE_SOURCE_DIR}/release) 403 | install(DIRECTORY ${OpenBLAS_DIR}/bin DESTINATION ${CMAKE_SOURCE_DIR}/release) 404 | else() 405 | # copy lib/ include/ and bin/ from ${INSTALL_DIR} to the release directory in 406 | # the root of the project 407 | install(DIRECTORY ${INSTALL_DIR}/lib DESTINATION ${CMAKE_SOURCE_DIR}/release) 408 | install(DIRECTORY ${INSTALL_DIR}/bin DESTINATION ${CMAKE_SOURCE_DIR}/release) 409 | install(DIRECTORY ${SOURCE_DIR}/include 410 | DESTINATION ${CMAKE_SOURCE_DIR}/release) 411 | install(DIRECTORY ${SOURCE_DIR}/ggml/include 412 | DESTINATION ${CMAKE_SOURCE_DIR}/release) 413 | 414 | if(APPLE) 415 | # copy the CoreML library to the release directory 416 | install( 417 | FILES 418 | ${BINARY_DIR}/src/${CMAKE_SHARED_LIBRARY_PREFIX}whisper.coreml${CMAKE_SHARED_LIBRARY_SUFFIX} 419 | DESTINATION ${CMAKE_SOURCE_DIR}/release/lib 420 | OPTIONAL) 421 | 422 | # Fix libomp linking and copy it to the release 423 | if($ENV{MACOS_ARCH} STREQUAL x86_64) 424 | list(APPEND CPU_BACKENDS 425 | libggml-cpu-x64.so 426 | libggml-cpu-sse42.so 427 | libggml-cpu-sandybridge.so 428 | libggml-cpu-haswell.so 429 | libggml-cpu-skylakex.so 430 | libggml-cpu-icelake.so 431 | libggml-cpu-alderlake.so 432 | libggml-cpu-sapphirerapids.so) 433 | else() 434 | list(APPEND CPU_BACKENDS 435 | libggml-cpu-apple_m1.so 436 | libggml-cpu-apple_m2_m3.so 437 | libggml-cpu-apple_m4.so) 438 | endif() 439 | # Fix libomp and Accelerate load paths 440 | foreach(CPU_BACKEND ${CPU_BACKENDS}) 441 | add_custom_command( 442 | TARGET Whispercpp_Build 443 | POST_BUILD 444 | COMMAND 445 | ${CMAKE_INSTALL_NAME_TOOL} -change "$ENV{OPENMP_PREFIX}/lib/libomp.dylib" 446 | "@loader_path/../Frameworks/libomp.dylib" 447 | "${INSTALL_DIR}/bin/${CPU_BACKEND}") 448 | endforeach(CPU_BACKEND ${CPU_BACKENDS}) 449 | add_custom_command( 450 | TARGET Whispercpp_Build 451 | POST_BUILD 452 | COMMAND 453 | ${CMAKE_INSTALL_NAME_TOOL} -change "@rpath/libvulkan.1.dylib" 454 | "@loader_path/../Frameworks/libvulkan.1.dylib" 455 | "${INSTALL_DIR}/bin/libggml-vulkan.so") 456 | 457 | install(FILES $ENV{OPENMP_PREFIX}/lib/libomp.dylib 458 | DESTINATION ${CMAKE_SOURCE_DIR}/release/lib) 459 | file(GLOB LIBOMP_HEADERS "$ENV{OPENMP_PREFIX}/include/*.h") 460 | install(FILES ${LIBOMP_HEADERS} 461 | DESTINATION ${CMAKE_SOURCE_DIR}/release/include) 462 | install(FILES /usr/local/lib/libvulkan.1.4.328.dylib 463 | DESTINATION ${CMAKE_SOURCE_DIR}/release/lib 464 | RENAME libvulkan.1.dylib) 465 | 466 | else() 467 | install( 468 | DIRECTORY ${INSTALL_DIR}/lib64 469 | DESTINATION ${CMAKE_SOURCE_DIR}/release 470 | OPTIONAL) 471 | file(GLOB LIBS_IN_LIB "${INSTALL_DIR}/lib/*${CMAKE_SHARED_LIBRARY_SUFFIX}") 472 | install( 473 | FILES ${LIBS_IN_LIB} 474 | DESTINATION ${CMAKE_SOURCE_DIR}/release/lib64 475 | OPTIONAL) 476 | file(GLOB LIBS_IN_LIB64 477 | "${INSTALL_DIR}/lib64/*${CMAKE_SHARED_LIBRARY_SUFFIX}") 478 | install( 479 | FILES ${LIBS_IN_LIB64} 480 | DESTINATION ${CMAKE_SOURCE_DIR}/release/lib 481 | OPTIONAL) 482 | endif() 483 | endif(WIN32) 484 | --------------------------------------------------------------------------------