Skip to content

Commit

Permalink
Add support for Intel MKL in build scripts and CMake configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Nov 25, 2024
1 parent 9207694 commit 1f5c0d1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
matrix:
config:
- "Release"
accel: [cpu, cuda, vulkan, hipblas]
accel: [cpu, cuda, vulkan, hipblas, mkl]

steps:
- name: "Get version"
Expand Down Expand Up @@ -168,6 +168,16 @@ jobs:
Start-Process "${env:RUNNER_TEMP}\VulkanSDK-1.3.296.0-Installer.exe" -ArgumentList '--accept-licenses --default-answer --confirm-command install' -NoNewWindow -Wait
write-host "Completed Vulkan SDK installation"
- name: "Install Intel MKL"
if: ${{ matrix.accel == 'mkl' }}
run: |
$ErrorActionPreference = "Stop"
write-host "Downloading Intel MKL"
Invoke-WebRequest -Uri "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/bcb40b43-4ca9-4725-9749-4f9fc1e9b97f/intel-onemkl-2025.0.1.15_offline.exe" -OutFile "${env:RUNNER_TEMP}\mkl.exe"
write-host "Installing Intel MKL"
Start-Process "${env:RUNNER_TEMP}\mkl.exe" -ArgumentList '/S' -NoNewWindow -Wait
write-host "Completed Intel MKL installation"
- name: "Run Build-Windows.ps1"
run: "./Build-Windows.ps1 -Version ${{ steps.get-version.outputs.version }}"
env:
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ include(FetchContent)

option(WHISPERCPP_WITH_CUDA "Build Whisper with CUDA support" OFF)
option(WHISPERCPP_WITH_HIPBLAS "Build Whisper with hipBLAS support" OFF)
option(WHISPERCPP_WITH_VULKAN "Build Whisper with Vulkan support" OFF)
option(WHISPERCPP_WITH_MKL "Build Whisper with MKL support" OFF)

set(CMAKE_OSX_ARCHITECTURES_ "$ENV{MACOS_ARCH}")

set(Whispercpp_Build_GIT_TAG "fdbfb460ed546452a5d53611bba66d10d842e719")
set(Whispercpp_Build_GIT_TAG "8c6a9b8bb6a0273cc0b5915903ca1ff9206c6285")

if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL
RelWithDebInfo)
Expand Down Expand Up @@ -75,6 +77,21 @@ if(WIN32)
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DGGML_HIPBLAS=ON
-DGGML_CUDA=OFF)
set(WHISPER_CMAKE_GENERATOR ${CMAKE_GENERATOR})
elseif(WHISPERCPP_WITH_MKL)
# Build with MKL
if(NOT DEFINED ENV{MKL_PATH})
message(
FATAL_ERROR
"MKL_PATH is not set. Please set it to the root directory of your MKL installation, e.g. `C:/Program Files (x86)/Intel/oneAPI/mkl/latest`"
)
endif(NOT DEFINED ENV{MKL_PATH})
cmake_path(SET MKL_PATH_STR NORMALIZE "$ENV{MKL_PATH}")
set(WHISPER_ADDITIONAL_ENV "CMAKE_PREFIX_PATH=${MKL_PATH_STR} WHISPER_MKL=1")
set(WHISPER_ADDITIONAL_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DWHISPER_MKL=ON
-DGGML_CUDA=OFF)
set(WHISPER_CMAKE_GENERATOR ${CMAKE_GENERATOR})
else()
# Build with OpenBLAS
set(OpenBLAS_URL
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ Set up environment variables, e.g.:
> $env:CUDA_TOOLKIT_ROOT_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5"
```

Acceleration options: `cpu`, `cuda` and `hipblas`
Acceleration options: `cpu`, `cuda`, `vulkan`, `mkl` and `hipblas`

For `hipblas` make sure `$env:HIP_PATH` points to the HIP installation folder, e.g. where `$env:HIP_PATH\bin\clang.exe` would be located.

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.

The Vulkan installer can be found in https://sdk.lunarg.com/sdk/download/1.3.296.0/windows/VulkanSDK-1.3.296.0-Installer.exe.

The MKL installer can be found in https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html.

Run the build script:

```powershell
Expand Down
22 changes: 20 additions & 2 deletions build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Param(
)

# check env var BUILD_WITH_ACCEL
if ($env:BUILD_WITH_ACCEL -eq $null) {
Write-Host "Please set env var BUILD_WITH_ACCEL to 'cpu', 'cuda', 'vulkan' or 'hipblas'."
if ($null -eq $env:BUILD_WITH_ACCEL) {
Write-Host "Please set env var BUILD_WITH_ACCEL to 'cpu', 'cuda', 'vulkan', `mkl` or 'hipblas'."
exit
}

Expand Down Expand Up @@ -32,6 +32,24 @@ if ($env:BUILD_WITH_ACCEL -eq "cpu") {
# find the Vulkan SDK version path in C:\VulkanSDK\
$vulkanSdkPath = Get-ChildItem -Path "C:\VulkanSDK" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
$env:VULKAN_SDK_PATH="$vulkanSdkPath"
} elseif ($env:BUILD_WITH_ACCEL -eq "mkl") {
$cmakeArgs += (
"-DWHISPERCPP_WITH_MKL=ON",
"-DCMAKE_GENERATOR=Visual Studio 17 2022"
)
$zipFileName = "whispercpp-windows-mkl-$Version.zip"
# find the MKL path in C:\Program Files (x86)\Intel\oneAPI
$mklPath = Get-ChildItem -Path "C:\Program Files (x86)\Intel\oneAPI" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
$env:MKL_PATH="$mklPath"
} elseif ($env:BUILD_WITH_ACCEL -eq "cuda") {
$cmakeArgs += (
"-DWHISPERCPP_WITH_CUDA=ON",
"-DCMAKE_GENERATOR=Visual Studio 17 2022"
)
$zipFileName = "whispercpp-windows-cuda-$Version.zip"
# find the CUDA path in C:\Program Files\NVIDIA GPU Computing Toolkit
$cudaPath = Get-ChildItem -Path "C:\Program Files\NVIDIA GPU Computing Toolkit" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
$env:CUDA_TOOLKIT_ROOT_DIR="$cudaPath"
} else {
$cmakeArgs += (
"-DWHISPERCPP_WITH_CUDA=ON",
Expand Down

0 comments on commit 1f5c0d1

Please sign in to comment.