diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 0bf15d9d2..01d853997 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -144,4 +144,4 @@ jobs: # alert-threshold: "200%" # comment-on-alert: true # fail-on-alert: true - # alert-comment-cc-users: "@louis030195" + # alert-comment-cc-users: "@louis030195" \ No newline at end of file diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml index 147f48a44..a8ce65d48 100644 --- a/.github/workflows/release-app.yml +++ b/.github/workflows/release-app.yml @@ -40,9 +40,11 @@ jobs: args: "--target x86_64-apple-darwin --features metal" target: x86_64-apple-darwin - platform: "ubuntu-22.04" # Ubuntu x86_64 - args: "" # TODO CUDA, mkl + args: "--features mkl" + target: x86_64-unknown-linux-gnu - platform: "windows-latest" # Windows x86_64 - args: "--target x86_64-pc-windows-msvc" # TODO CUDA, mkl? --features "openblas" + args: "--target x86_64-pc-windows-msvc --features mkl" + target: x86_64-pc-windows-msvc pre-build-args: "" # --openblas # windows arm: https://github.com/ahqsoftwares/tauri-ahq-store/blob/2fbc2103c222662b3c6ee0cd71fcde664824f0ef/.github/workflows/publish.yml#L136 @@ -147,9 +149,16 @@ jobs: shell: bash run: | if [[ "${{ matrix.platform }}" == "macos-latest" ]]; then + # These settings are specific to macOS builds export PKG_CONFIG_PATH="/usr/local/opt/ffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH" export PKG_CONFIG_ALLOW_CROSS=1 export RUSTFLAGS="-C link-arg=-Wl,-rpath,@executable_path/../Frameworks -C link-arg=-Wl,-rpath,@loader_path/../Frameworks -C link-arg=-Wl,-install_name,@rpath/libscreenpipe.dylib" + elif [[ "${{ matrix.platform }}" == "ubuntu-22.04" ]]; then + # Linux-specific settings (if any) + export RUSTFLAGS="-C target-cpu=native" + elif [[ "${{ matrix.platform }}" == "windows-latest" ]]; then + # Windows-specific settings (if any) + export RUSTFLAGS="-C target-cpu=native" fi cargo build --release ${{ matrix.args }} ls -R target diff --git a/screenpipe-audio/Cargo.toml b/screenpipe-audio/Cargo.toml index 06e0ba9bc..ee79e403e 100644 --- a/screenpipe-audio/Cargo.toml +++ b/screenpipe-audio/Cargo.toml @@ -84,6 +84,8 @@ metal = ["candle/metal", "candle-nn/metal", "candle-transformers/metal"] cuda = ["candle/cuda", "candle-nn/cuda", "candle-transformers/cuda"] mkl = ["candle/mkl", "candle-nn/mkl", "candle-transformers/mkl"] + + [[bin]] name = "screenpipe-audio" path = "src/bin/screenpipe-audio.rs" diff --git a/screenpipe-audio/benches/stt_benchmark.rs b/screenpipe-audio/benches/stt_benchmark.rs index 38da8044f..6df4fea4d 100644 --- a/screenpipe-audio/benches/stt_benchmark.rs +++ b/screenpipe-audio/benches/stt_benchmark.rs @@ -69,4 +69,4 @@ fn criterion_benchmark(c: &mut Criterion) { } criterion_group!(benches, criterion_benchmark); -criterion_main!(benches); +criterion_main!(benches); \ No newline at end of file diff --git a/screenpipe-audio/src/stt.rs b/screenpipe-audio/src/stt.rs index 87d5f0ee0..3d2bb79ba 100644 --- a/screenpipe-audio/src/stt.rs +++ b/screenpipe-audio/src/stt.rs @@ -40,8 +40,8 @@ pub struct WhisperModel { impl WhisperModel { pub fn new(engine: Arc) -> Result { debug!("Initializing WhisperModel"); - let device = Device::new_metal(0).unwrap_or(Device::new_cuda(0).unwrap_or(Device::Cpu)); - info!("device = {:?}", device); + let device = Self::get_optimal_device()?; + info!("Using device: {:?}", device); debug!("Fetching model files"); let (config_filename, tokenizer_filename, weights_filename) = { @@ -86,6 +86,28 @@ impl WhisperModel { device, }) } + + fn get_optimal_device() -> Result { + #[cfg(target_os = "macos")] + { + if let Ok(device) = Device::new_metal(0) { + info!("Using Metal GPU"); + return Ok(device); + } + } + + #[cfg(not(target_os = "macos"))] + { + if let Ok(device) = Device::new_cuda(0) { + info!("Using CUDA GPU"); + return Ok(device); + } + } + + info!("GPU not available, falling back to CPU"); + Ok(Device::Cpu) + } + } #[derive(Debug, Clone)]