Skip to content

Commit

Permalink
Bump whisper.cpp version
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Aug 29, 2024
1 parent 9871dd6 commit 77e8a07
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 20 deletions.
34 changes: 15 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option(WHISPERCPP_WITH_HIPBLAS "Build Whisper with hipBLAS support" OFF)

set(CMAKE_OSX_ARCHITECTURES_ "$ENV{MACOS_ARCH}")

set(Whispercpp_Build_GIT_TAG "f68298ce06ca3edd6e6f3f21c3d0bb5f073942c3")
set(Whispercpp_Build_GIT_TAG "c4e1861d2c24b186cbbac6c07480aaa298b0e6d9")

if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL
RelWithDebInfo)
Expand Down Expand Up @@ -41,18 +41,9 @@ endif()

if(WIN32)
if(WHISPERCPP_WITH_CUDA)
# Build with CUDA Check that CUDA_TOOLKIT_ROOT_DIR is set
if(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR)
message(
FATAL_ERROR
"CUDA_TOOLKIT_ROOT_DIR is not set. Please set it to the root directory of your CUDA "
"installation, e.g. `C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4`"
)
endif(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR)

set(WHISPER_ADDITIONAL_ENV "CUDAToolkit_ROOT=${CUDA_TOOLKIT_ROOT_DIR}")
set(WHISPER_ADDITIONAL_CMAKE_ARGS
-DGGML_CUDA=ON -DCMAKE_GENERATOR_TOOLSET=cuda=${CUDA_TOOLKIT_ROOT_DIR})
# Build with CUDA
set(WHISPER_ADDITIONAL_ENV "")
set(WHISPER_ADDITIONAL_CMAKE_ARGS -DGGML_CUDA=ON)
set(WHISPER_CMAKE_GENERATOR ${CMAKE_GENERATOR})
elseif(WHISPERCPP_WITH_HIPBLAS)
# Build with hipBLAS
Expand Down Expand Up @@ -104,12 +95,8 @@ if(WIN32)
<INSTALL_DIR>/bin/${CMAKE_SHARED_LIBRARY_PREFIX}whisper${CMAKE_SHARED_LIBRARY_SUFFIX}
<INSTALL_DIR>/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}whisper${CMAKE_IMPORT_LIBRARY_SUFFIX}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
INSTALL_COMMAND
${CMAKE_COMMAND} --install <BINARY_DIR> --config ${Whispercpp_BUILD_TYPE}
&& ${CMAKE_COMMAND} -E copy
<BINARY_DIR>/${Whispercpp_BUILD_TYPE}/whisper.lib <INSTALL_DIR>/lib &&
${CMAKE_COMMAND} -E copy <SOURCE_DIR>/ggml/include/ggml.h
<INSTALL_DIR>/include
INSTALL_COMMAND ${CMAKE_COMMAND} --install <BINARY_DIR> --config
${Whispercpp_BUILD_TYPE}
CONFIGURE_COMMAND
${CMAKE_COMMAND} -E env ${WHISPER_ADDITIONAL_ENV} ${CMAKE_COMMAND}
<SOURCE_DIR> -B <BINARY_DIR> -G ${WHISPER_CMAKE_GENERATOR}
Expand Down Expand Up @@ -179,6 +166,15 @@ if(WIN32)
"${HIP_PATH_STR}/bin/amd_comgr_2.dll")
install(FILES ${HIPBLAS_DLLS} DESTINATION ${CMAKE_SOURCE_DIR}/release/bin)
else()
# Check that CUDA_TOOLKIT_ROOT_DIR is set
if(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR)
message(
FATAL_ERROR
"CUDA_TOOLKIT_ROOT_DIR is not set. Please set it to the root directory of your CUDA "
"installation, e.g. `C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4`"
)
endif(NOT DEFINED CUDA_TOOLKIT_ROOT_DIR)

# normalize CUDA path with file(TO_CMAKE_PATH)
file(TO_CMAKE_PATH ${CUDA_TOOLKIT_ROOT_DIR} CUDA_TOOLKIT_ROOT_DIR)
# find the CUDA DLLs for cuBLAS in the bin directory of the CUDA
Expand Down
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# occ-ai-dep-whispercpp
# Whisper.cpp prebuilt binaries
Whisper.cpp prebuilt binaries for static and dynamic linking

## Building on Windows

You will need MSVS 2022 installed.

Set up environment variables, e.g.:

```powershell
> $env:BUILD_WITH_ACCEL="cuda"
> $env:CUDA_TOOLKIT_ROOT_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5"
```

Acceleration options: `cpu`, `cuda` 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.

Run the build script:

```powershell
> ./Build-Windows.ps1 -Version 0.0.6
```

## Building on Mac OS

Set the `MACOS_ARCH` env variable to `x86_64` or `arm64`:

```bash
$ export MACOS_ARCH=x86_64
```

Run the build script:

```bash
$ ./build-macos.sh 0.0.6
```
4 changes: 4 additions & 0 deletions build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if ($env:BUILD_WITH_ACCEL -eq $null) {
exit
}

$env:CMAKE_TOOLCHAIN_FILE=""
$env:VCPKG_ROOT=""

$cmakeArgs = @()
if ($env:BUILD_WITH_ACCEL -eq "cpu") {
$cmakeArgs += ("-DWHISPERCPP_WITH_CUDA=OFF")
Expand All @@ -23,6 +26,7 @@ if ($env:BUILD_WITH_ACCEL -eq "cpu") {
} else {
$cmakeArgs += (
"-DWHISPERCPP_WITH_CUDA=ON",
"-DCMAKE_GENERATOR=Visual Studio 17 2022",
"-DCUDA_TOOLKIT_ROOT_DIR=$env:CUDA_TOOLKIT_ROOT_DIR"
)
$zipFileName = "whispercpp-windows-cuda-$Version.zip"
Expand Down

0 comments on commit 77e8a07

Please sign in to comment.