parent
e6cbc75430
commit
d6da605de1
7 changed files with 3 additions and 130 deletions
37
BUILDING.md
37
BUILDING.md
|
|
@ -44,39 +44,4 @@ You also need to have CMake installed. You can obtain this using homebrew:
|
||||||
brew install cmake
|
brew install cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
CMake can also be installed from https://cmake.org/download/ but `cmake` binary needs to be in your PATH.
|
CMake can also be installed from https://cmake.org/download/ but `cmake` binary needs to be in your PATH.
|
||||||
|
|
||||||
# OpenVINO support
|
|
||||||
|
|
||||||
## Development Tools
|
|
||||||
OpenVINO support requires the OpenVINO Development Tools to be installed. You can find
|
|
||||||
instructions for installing the OpenVINO Development Tools here:
|
|
||||||
https://docs.openvino.ai/2023.0/openvino_docs_install_guides_install_dev_tools.html#for-c-developers
|
|
||||||
|
|
||||||
On Arch Linux, you can install the OpenVINO Development Tools with the following command:
|
|
||||||
```
|
|
||||||
paru -S openvino
|
|
||||||
```
|
|
||||||
This build may take a significant amount of time, but can save massive headaches later on.
|
|
||||||
|
|
||||||
## Building
|
|
||||||
First, the `openvino` feature must be enabled in your Cargo.toml.
|
|
||||||
|
|
||||||
Next, you must set the `OpenVINO_DIR` environment variable to the path where CMake can find
|
|
||||||
`OpenVINOConfig.cmake`, and the `OpenVINO_SO_DIR` tothe path where the OpenVINO shared
|
|
||||||
libraries are located.
|
|
||||||
The former is usually in the `runtime/cmake` directory of the OpenVINO installation, and the latter
|
|
||||||
is usually in `runtime/lib/intel64`.
|
|
||||||
|
|
||||||
If you used the AUR package to install OpenVINO, the location of this file is `/opt/intel/openvino/runtime/cmake`.
|
|
||||||
|
|
||||||
```
|
|
||||||
export OpenVINO_DIR=/opt/intel/openvino/runtime/cmake
|
|
||||||
```
|
|
||||||
|
|
||||||
Finally, you can build whisper-rs as normal.
|
|
||||||
|
|
||||||
## Tested platforms
|
|
||||||
- Arch Linux
|
|
||||||
|
|
||||||
If you have successfully built whisper-rs with OpenVINO on another platform, please open a PR to document it here!
|
|
||||||
|
|
@ -26,7 +26,6 @@ simd = []
|
||||||
coreml = ["whisper-rs-sys/coreml"]
|
coreml = ["whisper-rs-sys/coreml"]
|
||||||
cuda = ["whisper-rs-sys/cuda"]
|
cuda = ["whisper-rs-sys/cuda"]
|
||||||
opencl = ["whisper-rs-sys/opencl"]
|
opencl = ["whisper-rs-sys/opencl"]
|
||||||
openvino = ["whisper-rs-sys/openvino"]
|
|
||||||
test-with-tiny-model = []
|
test-with-tiny-model = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,7 @@ See the docs: https://docs.rs/whisper-rs/ for more details.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
See [BUILDING.md](BUILDING.md) for instructions for building whisper-rs on Windows and OSX M1,
|
See [BUILDING.md](BUILDING.md) for instructions for building whisper-rs on Windows and OSX M1. Linux builds should just work out of the box.
|
||||||
or with OpenVINO on any OS.
|
|
||||||
Besides OpenVINO, Linux builds should just work out of the box.
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,49 +56,6 @@ impl WhisperContext {
|
||||||
|
|
||||||
// we don't implement `whisper_init()` here since i have zero clue what `whisper_model_loader` does
|
// we don't implement `whisper_init()` here since i have zero clue what `whisper_model_loader` does
|
||||||
|
|
||||||
/// Using this context, enable use of OpenVINO for encoder inference.
|
|
||||||
///
|
|
||||||
/// # Arguments
|
|
||||||
/// * `model_path`: An optional path to the OpenVINO encoder IR model.
|
|
||||||
/// If set to `None`,
|
|
||||||
/// the path will be generated from the ggml model path
|
|
||||||
/// that was passed in to whisper_init_from_file.
|
|
||||||
/// For example, if the model path was "/path/to/ggml-base.en.bin",
|
|
||||||
/// then the OpenVINO IR model path will be assumed as "/path/to/ggml-base.en-encoder-openvino.xml".
|
|
||||||
///
|
|
||||||
/// * `device`: The OpenVINO device to use for inference (e.g. "CPU", "GPU")
|
|
||||||
///
|
|
||||||
/// * `cache_dir`: Optional cache directory that can speed up init time,
|
|
||||||
/// especially for GPU, by caching compiled 'blobs' there.
|
|
||||||
/// Set to nullptr if not used.
|
|
||||||
///
|
|
||||||
/// # Returns
|
|
||||||
/// `true` on success, `false` if OpenVINO was not enabled at compile time
|
|
||||||
/// (enable the `openvino` feature flag in your Cargo.toml).
|
|
||||||
///
|
|
||||||
/// # C++ equivalent
|
|
||||||
/// `int whisper_ctx_init_openvino_encoder(struct whisper_context * ctx, const char * model_path, const char * device, const char * cache_dir);`
|
|
||||||
#[cfg(feature = "openvino")]
|
|
||||||
pub fn init_openvino_encoder(
|
|
||||||
&mut self,
|
|
||||||
model_path: Option<&str>,
|
|
||||||
device: &str,
|
|
||||||
cache_dir: Option<&str>,
|
|
||||||
) -> bool {
|
|
||||||
let model_path = model_path.map(|s| CString::new(s).unwrap());
|
|
||||||
let device = CString::new(device).unwrap();
|
|
||||||
let cache_dir = cache_dir.map(|s| CString::new(s).unwrap());
|
|
||||||
let ret = unsafe {
|
|
||||||
whisper_rs_sys::whisper_ctx_init_openvino_encoder(
|
|
||||||
self.ctx,
|
|
||||||
model_path.map(|s| s.as_ptr()).unwrap_or(std::ptr::null()),
|
|
||||||
device.as_ptr(),
|
|
||||||
cache_dir.map(|s| s.as_ptr()).unwrap_or(std::ptr::null()),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
ret != 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new state object, ready for use.
|
/// Create a new state object, ready for use.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ include = [
|
||||||
coreml = []
|
coreml = []
|
||||||
cuda = []
|
cuda = []
|
||||||
opencl = []
|
opencl = []
|
||||||
openvino = []
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
|
|
||||||
45
sys/build.rs
45
sys/build.rs
|
|
@ -7,43 +7,6 @@ use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Fail-fast test for OpenVINO
|
|
||||||
#[cfg(feature = "openvino")]
|
|
||||||
{
|
|
||||||
if let Ok(openvino_dir) = env::var("OpenVINO_DIR") {
|
|
||||||
// see if we can find OpenVINOConfig.cmake
|
|
||||||
let openvino_config_path = PathBuf::from(&openvino_dir).join("OpenVINOConfig.cmake");
|
|
||||||
if !openvino_config_path.exists() {
|
|
||||||
panic!(
|
|
||||||
"Couldn't find OpenVINOConfig.cmake in OpenVINO_DIR. Please set it to the path where `OpenVINOConfig.cmake` can be found.\n\
|
|
||||||
On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/cmake/`.\n\
|
|
||||||
Note the `/cmake/` at the end of the path."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic!(
|
|
||||||
"Couldn't find the OpenVINO_DIR environment variable. Please set it to the path where `OpenVINOConfig.cmake` can be found.\n\
|
|
||||||
On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/cmake/`."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(openvino_so_dir) = env::var("OpenVINO_SO_DIR") {
|
|
||||||
// check if `libopenvino.so` exists in the directory
|
|
||||||
let openvino_so_path = PathBuf::from(&openvino_so_dir).join("libopenvino.so");
|
|
||||||
if !openvino_so_path.exists() {
|
|
||||||
panic!(
|
|
||||||
"Couldn't find libopenvino.so in OpenVINO_SO_DIR. Please set it to the path where `libopenvino.so` can be found.\n\
|
|
||||||
On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/lib/intel64/`."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic!(
|
|
||||||
"Couldn't find the OpenVINO_SO_DIR environment variable. Please set it to the path where `libopenvino.so` can be found.\n\
|
|
||||||
On Arch Linux, if you installed the AUR package, this path is `/opt/intel/openvino/runtime/lib/intel64/`."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let target = env::var("TARGET").unwrap();
|
let target = env::var("TARGET").unwrap();
|
||||||
// Link C++ standard library
|
// Link C++ standard library
|
||||||
if let Some(cpp_stdlib) = get_cpp_link_stdlib(&target) {
|
if let Some(cpp_stdlib) = get_cpp_link_stdlib(&target) {
|
||||||
|
|
@ -84,11 +47,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "openvino")]
|
|
||||||
{
|
|
||||||
println!("cargo:rustc-link-lib=openvino");
|
|
||||||
println!("cargo:rustc-link-search={}", env::var("OpenVINO_SO_DIR").unwrap());
|
|
||||||
}
|
|
||||||
println!("cargo:rerun-if-changed=wrapper.h");
|
println!("cargo:rerun-if-changed=wrapper.h");
|
||||||
|
|
||||||
if env::var("WHISPER_DONT_GENERATE_BINDINGS").is_ok() {
|
if env::var("WHISPER_DONT_GENERATE_BINDINGS").is_ok() {
|
||||||
|
|
@ -154,9 +112,6 @@ fn main() {
|
||||||
#[cfg(feature = "opencl")]
|
#[cfg(feature = "opencl")]
|
||||||
cmd.arg("-DWHISPER_CLBLAST=ON");
|
cmd.arg("-DWHISPER_CLBLAST=ON");
|
||||||
|
|
||||||
#[cfg(feature = "openvino")]
|
|
||||||
cmd.arg("-DWHISPER_OPENVINO=1");
|
|
||||||
|
|
||||||
cmd.arg("-DCMAKE_POSITION_INDEPENDENT_CODE=ON");
|
cmd.arg("-DCMAKE_POSITION_INDEPENDENT_CODE=ON");
|
||||||
|
|
||||||
let code = cmd
|
let code = cmd
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8e46ba80d3c1dcf532a0029f9bcdf99ce9ce7d40
|
Subproject commit 54735be80f85fec2b08b09b44641b2698dbdef79
|
||||||
Loading…
Add table
Add a link
Reference in a new issue