Skip to content

Commit 1b5233b

Browse files
committed
Add CPU feature validation for whisper.cpp compatibility
- Check for required SSE2 support before creating whisper state - Log AVX availability for performance diagnostics - Prevent crashes on CPUs missing required instruction sets
1 parent 76cbc24 commit 1b5233b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/whisper-local/src/model.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ impl WhisperBuilder {
6161
log::info!("WhisperContext created successfully");
6262

6363
log::info!("Creating WhisperState...");
64+
log::info!("Validating CPU features...");
65+
66+
// Check if CPU supports required features for whisper.cpp
67+
#[cfg(target_arch = "x86_64")]
68+
{
69+
if !std::arch::is_x86_feature_detected!("sse2") {
70+
log::error!("CPU missing SSE2 support required for whisper.cpp");
71+
return Err(crate::error::Error::LocalWhisperError(whisper_rs::WhisperError::InitError));
72+
}
73+
log::info!("✓ CPU has SSE2 support");
74+
75+
if std::arch::is_x86_feature_detected!("avx") {
76+
log::info!("✓ CPU has AVX support");
77+
} else {
78+
log::warn!("CPU missing AVX - performance may be reduced");
79+
}
80+
}
81+
6482
log::info!("About to call ctx.create_state()");
6583

6684
let state = match std::panic::catch_unwind(|| ctx.create_state()) {

0 commit comments

Comments
 (0)