Skip to content

Commit 323df2d

Browse files
committed
Upgrade to use upstream OpenVINO 2022.1 release
The 2022 release changes the names of several of the shared libraries produced by OpenVINO as well as their directory structure. The C API is still available, however, so this change continues to use that for the time being instead of the newer v2.0 API. Because of the significant changes to the release structure, there is a decision to be made regarding backwards compatibility--e.g., using older versions of OpenVINO with this binding crate. This change makes the decision to stop supporting pre-2022 installations of OpenVINO in ongoing versions of this crate: once this crate is released (`v0.4.0`), users will have to decide whether to use this version for the newest versions of OpenVINO or downgrade to a previously-released crate (`v0.3.*`) for pre-2022 versions of OpenVINO.
1 parent c4d0a9e commit 323df2d

File tree

7 files changed

+34
-50
lines changed

7 files changed

+34
-50
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ jobs:
6161
fail-fast: false
6262
matrix:
6363
os: [ubuntu18, ubuntu20]
64-
version: [2020.4, 2021.1, 2021.2, 2021.3, 2021.4]
65-
exclude:
66-
- os: ubuntu20
67-
version: 2020.4
64+
version: [2022.1.0]
6865
steps:
6966
- uses: actions/checkout@v2
7067
with:
@@ -79,18 +76,18 @@ jobs:
7976
# binaries, then compile against these).
8077
runtime_binaries:
8178
name: From runtime-linked binaries
82-
runs-on: ubuntu-18.04
79+
runs-on: ubuntu-latest
8380
steps:
8481
- uses: actions/checkout@v2
8582
with:
8683
submodules: recursive
8784
lfs: true
8885
- name: Checkout LFS obects
8986
run: git lfs checkout
90-
- uses: abrown/install-openvino-action@v1
87+
- uses: abrown/install-openvino-action@v3
9188
- name: Build and run tests
9289
run: |
93-
source /opt/intel/openvino/bin/setupvars.sh
90+
source /opt/intel/openvino_2022/setupvars.sh
9491
cargo test --features openvino-sys/runtime-linking
9592
9693
# Build and test from an existing OpenVINO installation inside a Docker image (i.e. download the

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ RUN OPENVINO_INSTALL_DIR=/opt/intel/openvino cargo build -vv
2525

2626
# Test; note that we need to setup the library paths before using them since the
2727
# OPENVINO_INSTALL_DIR can only affect the build library search path.
28-
RUN ["/bin/bash", "-c", "source /opt/intel/openvino/bin/setupvars.sh && OPENVINO_INSTALL_DIR=/opt/intel/openvino cargo test -v"]
28+
RUN ["/bin/bash", "-c", "source /opt/intel/openvino/setupvars.sh && OPENVINO_INSTALL_DIR=/opt/intel/openvino cargo test -v"]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ git lfs checkout
3535

3636
```shell script
3737
cargo build
38-
source /opt/intel/openvino/bin/setupvars.sh
38+
source /opt/intel/openvino/setupvars.sh
3939
cargo test
4040
```
4141

@@ -55,7 +55,7 @@ script will do this automatically.
5555

5656
```shell script
5757
cargo build --features openvino-sys/runtime-linking
58-
source /opt/intel/openvino/bin/setupvars.sh
58+
source /opt/intel/openvino/setupvars.sh
5959
cargo test --features openvino-sys/runtime-linking
6060
```
6161

@@ -64,7 +64,7 @@ The `openvino-rs` crates also support linking from a shared library at runtime (
6464
present and only later--at runtime--providing the OpenVINO™ shared libraries. All underlying system
6565
calls are wrapped so that a call to `openvino_sys::library::load` will link them to their shared
6666
library implementation (using the logic in [openvino-finder] to locate the shared libraries). For
67-
high-level users, call `openvino::Core::new` first to automatically load and link the libraries.
67+
high-level users, call `openvino::Core::new` first to automatically load and link the libraries.
6868

6969

7070

crates/openvino-finder/src/lib.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
3636
}
3737

3838
// Search using the `OPENVINO_INSTALL_DIR` environment variable; this may be set by users of the
39-
// openvino-rs library.
39+
// `openvino-rs` library.
4040
if let Some(install_dir) = env::var_os(ENV_OPENVINO_INSTALL_DIR) {
4141
let install_dir = PathBuf::from(install_dir);
4242
for lib_dir in KNOWN_INSTALLATION_SUBDIRECTORIES {
@@ -46,7 +46,7 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
4646
}
4747

4848
// Search using the `OPENVINO_BUILD_DIR` environment variable; this may be set by users of the
49-
// openvino-rs library.
49+
// `openvino-rs` library.
5050
if let Some(build_dir) = env::var_os(ENV_OPENVINO_BUILD_DIR) {
5151
let install_dir = PathBuf::from(build_dir);
5252
for lib_dir in KNOWN_BUILD_SUBDIRECTORIES {
@@ -56,7 +56,7 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
5656
}
5757

5858
// Search using the `INTEL_OPENVINO_DIR` environment variable; this is set up by an OpenVINO
59-
// installation (e.g. `source /opt/intel/openvino/bin/setupvars.sh`).
59+
// installation (e.g. `source /opt/intel/openvino/setupvars.sh`).
6060
if let Some(install_dir) = env::var_os(ENV_INTEL_OPENVINO_DIR) {
6161
let install_dir = PathBuf::from(install_dir);
6262
for lib_dir in KNOWN_INSTALLATION_SUBDIRECTORIES {
@@ -66,8 +66,7 @@ pub fn find(library_name: &str) -> Option<PathBuf> {
6666
}
6767

6868
// Search in the OS library path (i.e. `LD_LIBRARY_PATH` on Linux, `PATH` on Windows, and
69-
// `DYLD_LIBRARY_PATH` on MacOS). See
70-
// https://docs.openvinotoolkit.org/latest/openvino_docs_IE_DG_Deep_Learning_Inference_Engine_DevGuide.html
69+
// `DYLD_LIBRARY_PATH` on MacOS).
7170
if let Some(path) = env::var_os(ENV_LIBRARY_PATH) {
7271
for lib_dir in env::split_paths(&path) {
7372
let search_path = lib_dir.join(&file);
@@ -110,24 +109,19 @@ cfg_if! {
110109
cfg_if! {
111110
if #[cfg(any(target_os = "linux", target_os = "macos"))] {
112111
const DEFAULT_INSTALLATION_DIRECTORIES: & [& str] =
113-
&["/opt/intel/openvino_2021", "/opt/intel/openvino"];
112+
&["/opt/intel/openvino_2022", "/opt/intel/openvino"];
114113
} else if #[cfg(target_os = "windows")] {
115114
const DEFAULT_INSTALLATION_DIRECTORIES: & [& str] = &[
115+
"C:\\Program Files (x86)\\Intel\\openvino_2022",
116116
"C:\\Program Files (x86)\\Intel\\openvino",
117-
"C:\\Program Files (x86)\\Intel\\openvino_2021",
118117
];
119118
} else {
120119
const DEFAULT_INSTALLATION_DIRECTORIES: & [& str] = &[];
121120
}
122121
}
123122

124-
const KNOWN_INSTALLATION_SUBDIRECTORIES: &[&str] = &[
125-
"deployment_tools/ngraph/lib",
126-
"deployment_tools/inference_engine/lib/intel64",
127-
"deployment_tools/inference_engine/external/hddl/lib",
128-
"deployment_tools/inference_engine/external/gna/lib",
129-
"deployment_tools/inference_engine/external/tbb/lib",
130-
];
123+
const KNOWN_INSTALLATION_SUBDIRECTORIES: &[&str] =
124+
&["runtime/lib/intel64", "runtime/3rdparty/tbb/lib"];
131125

132126
const KNOWN_BUILD_SUBDIRECTORIES: &[&str] = &[
133127
"bin/intel64/Debug/lib",
@@ -139,11 +133,11 @@ const KNOWN_BUILD_SUBDIRECTORIES: &[&str] = &[
139133
mod test {
140134
use super::*;
141135

142-
/// This test uses `find` to search for the `inference_engine_c_api` library on the local
136+
/// This test uses `find` to search for the `openvino_c` library on the local
143137
/// system.
144138
#[test]
145-
fn find_inference_engine_c_api_locally() {
139+
fn find_openvino_c_locally() {
146140
pretty_env_logger::init();
147-
assert!(find("inference_engine_c_api").is_some());
141+
assert!(find("openvino_c").is_some());
148142
}
149143
}

crates/openvino-sys/build.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ use std::env;
22
use std::path::{Path, PathBuf};
33

44
// These are the libraries we expect to be available to dynamically link to:
5-
const LIBRARIES: &[&str] = &[
6-
"inference_engine",
7-
"inference_engine_legacy",
8-
"inference_engine_transformations",
9-
"inference_engine_c_api",
10-
"ngraph",
11-
"tbb",
12-
];
5+
const LIBRARIES: &[&str] = &["openvino", "openvino_c", "tbb"];
136

147
// A user-specified environment variable indicating that `build.rs` should not attempt to link
158
// against any libraries (e.g. a doc build, user may link them later).
@@ -50,8 +43,8 @@ fn main() {
5043
let (c_api_library_path, library_search_paths) = if cfg!(feature = "from-source") {
5144
build_from_source_using_cmake()
5245
} else if linking == Linking::None {
53-
(openvino_finder::find("inference_engine_c_api"), vec![])
54-
} else if let Some(path) = openvino_finder::find("inference_engine_c_api") {
46+
(openvino_finder::find("openvino_c"), vec![])
47+
} else if let Some(path) = openvino_finder::find("openvino_c") {
5548
(Some(path), find_libraries_in_existing_installation())
5649
} else {
5750
panic!("Unable to find an OpenVINO installation on your system; build with runtime linking using `--features runtime-linking` or build from source with `--features from-source`.")
@@ -63,7 +56,7 @@ fn main() {
6356
if let Some(path) = c_api_library_path {
6457
record_library_path(path);
6558
} else {
66-
println!("cargo:warning=openvino-sys cannot find the `inference_engine_c_api` library in any of the library search paths: {:?}", &library_search_paths);
59+
println!("cargo:warning=openvino-sys cannot find the `openvino_c` library in any of the library search paths: {:?}", &library_search_paths);
6760
println!("cargo:warning=Proceeding with an empty value of {}; users must specify this location at runtime, e.g. `Core::new(Some(...))`.", ENV_OPENVINO_LIB_PATH);
6861
record_library_path(PathBuf::new());
6962
}
@@ -194,12 +187,12 @@ fn build_from_source_using_cmake() -> (Option<PathBuf>, Vec<PathBuf>) {
194187
}
195188

196189
// Specifying the build targets reduces the build time somewhat; this one will trigger
197-
// builds for other necessary shared libraries (e.g. inference_engine).
190+
// builds for other necessary shared libraries (e.g., `openvino`).
198191
let build_path = cmake(out.to_str().unwrap())
199-
.build_target("inference_engine_c_api")
192+
.build_target("openvino_c")
200193
.build();
201194

202-
// Unfortunately, `inference_engine_c_api` will not build the OpenVINO plugins used for
195+
// Unfortunately, `openvino_c` will not build the OpenVINO plugins used for
203196
// the actual computation. Here we re-run CMake for each plugin the user specifies using
204197
// Cargo features (see `Cargo.toml`).
205198
for plugin in get_plugin_target_from_features() {
@@ -228,7 +221,7 @@ fn build_from_source_using_cmake() -> (Option<PathBuf>, Vec<PathBuf>) {
228221
.expect("failed visiting TBB directory");
229222

230223
let c_api = format!(
231-
"{}inference_engine_c_api{}",
224+
"{}openvino_c{}",
232225
env::consts::DLL_PREFIX,
233226
env::consts::DLL_SUFFIX
234227
);

crates/openvino-sys/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ pub mod library {
4040
pub use super::generated::load;
4141

4242
/// Return the location of the shared library `openvino-sys` will link to. If compiled with
43-
/// runtime linking, this will attempt to discover the location of a `inference_engine_c_api`
44-
/// shared library on the system. Otherwise (with dynamic linking or compilation from source),
45-
/// this relies on a static path discovered at build time.
43+
/// runtime linking, this will attempt to discover the location of a `openvino_c` shared library
44+
/// on the system. Otherwise (with dynamic linking or compilation from source), this relies on a
45+
/// static path discovered at build time.
4646
///
4747
/// Knowing the location of the OpenVINO libraries is critical to avoid errors, unfortunately.
4848
/// OpenVINO loads target-specific libraries on demand for performing inference. To do so, it
@@ -53,7 +53,7 @@ pub mod library {
5353
/// `find().unwrap().parent()`.
5454
pub fn find() -> Option<PathBuf> {
5555
if cfg!(feature = "runtime-linking") {
56-
openvino_finder::find("inference_engine_c_api")
56+
openvino_finder::find("openvino_c")
5757
} else {
5858
Some(PathBuf::from(env!("OPENVINO_LIB_PATH")))
5959
}

crates/openvino-sys/src/linking/runtime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ macro_rules! link {
7777
/// May fail if the `openvino-finder` cannot discover the library on the current system.
7878
pub fn load() -> Result<(), String> {
7979
match crate::library::find() {
80-
None => Err("Unable to find the `inference_engine_c_api` library to load".into()),
80+
None => Err("Unable to find the `openvino_c` library to load".into()),
8181
Some(path) => load_from(path),
8282
}
8383
}
@@ -111,10 +111,10 @@ macro_rules! link {
111111
pub unsafe fn $name($($pname: $pty), *) $(-> $ret)* {
112112
let f = with_library(|l| {
113113
l.functions.$name.expect(concat!(
114-
"`inference_engine_c_api` function not loaded: `",
114+
"`openvino_c` function not loaded: `",
115115
stringify!($name)
116116
))
117-
}).expect("an `inference_engine_c_api` shared library is not loaded on this thread");
117+
}).expect("an `openvino_c` shared library is not loaded on this thread");
118118
f($($pname), *)
119119
}
120120
)+

0 commit comments

Comments
 (0)