From e33cc3eb2206df53a533bba0b177f0f5036f9fa7 Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Sun, 18 Aug 2024 21:23:46 +0300 Subject: [PATCH 1/2] feat: add vulkan with new whisper.cpp structure Co-authored-by: newfla --- Cargo.toml | 1 + README.md | 1 + sys/Cargo.toml | 1 + sys/build.rs | 18 ++++++++++++++++++ sys/whisper.cpp | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d7fbb14..8550bee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ cuda = ["whisper-rs-sys/cuda", "_gpu"] hipblas = ["whisper-rs-sys/hipblas", "_gpu"] openblas = ["whisper-rs-sys/openblas"] metal = ["whisper-rs-sys/metal", "_gpu"] +vulkan = ["whisper-rs-sys/vulkan", "_gpu"] _gpu = [] test-with-tiny-model = [] whisper-cpp-log = ["dep:log"] diff --git a/README.md b/README.md index 5e43a84..fb16a90 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ All disabled by default unless otherwise specified. * `hipblas`: enable ROCm/hipBLAS support. Only available on linux. Implicitly enables hidden GPU flag at runtime. * `openblas`: enable OpenBLAS support. * `metal`: enable Metal support. Implicitly enables hidden GPU flag at runtime. +* `vulkan`: enable Vulkan support. Implicitly enables hidden GPU flag at runtime. * `whisper-cpp-log`: allows hooking into whisper.cpp's log output and sending it to the `log` backend. Requires calling * `whisper-cpp-tracing`: allows hooking into whisper.cpp's log output and sending it to the `tracing` backend. diff --git a/sys/Cargo.toml b/sys/Cargo.toml index 0f84d90..f4eb1dd 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -45,6 +45,7 @@ cuda = [] hipblas = [] openblas = [] metal = [] +vulkan = [] force-debug = [] openmp = [] diff --git a/sys/build.rs b/sys/build.rs index 2b88ff0..98c9510 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -166,6 +166,24 @@ fn main() { } } + if cfg!(feature = "vulkan") { + config.define("GGML_VULKAN", "ON"); + if cfg!(windows) { + println!("cargo:rerun-if-env-changed=VULKAN_SDK"); + println!("cargo:rustc-link-lib=vulkan-1"); + let vulkan_path = match env::var("VULKAN_SDK") { + Ok(path) => PathBuf::from(path), + Err(_) => panic!( + "Please install Vulkan SDK and ensure that VULKAN_SDK env variable is set" + ), + }; + let vulkan_lib_path = vulkan_path.join("Lib"); + println!("cargo:rustc-link-search={}", vulkan_lib_path.display()); + } else { + println!("cargo:rustc-link-lib=vulkan"); + } + } + if cfg!(feature = "openblas") { config.define("GGML_BLAS", "ON"); } diff --git a/sys/whisper.cpp b/sys/whisper.cpp index 4b7de08..fe36c90 160000 --- a/sys/whisper.cpp +++ b/sys/whisper.cpp @@ -1 +1 @@ -Subproject commit 4b7de08bfdc1bdd07d7727bc4f299b9bffec8f2a +Subproject commit fe36c909715e6751277ddb020e7892c7670b61d4 From fdc290e37ff6093f5b7525923c041ffc7556addb Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:28:08 +0300 Subject: [PATCH 2/2] chore: update whisper.cpp --- sys/whisper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/whisper.cpp b/sys/whisper.cpp index fe36c90..9e3c534 160000 --- a/sys/whisper.cpp +++ b/sys/whisper.cpp @@ -1 +1 @@ -Subproject commit fe36c909715e6751277ddb020e7892c7670b61d4 +Subproject commit 9e3c5345cd46ea718209db53464e426c3fe7a25e