summaryrefslogtreecommitdiffstats
path: root/container-onnxruntime
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2022-12-07 08:57:31 +0000
committerArne Juul <arnej@yahooinc.com>2022-12-07 08:57:57 +0000
commit8c6d30c4b4fff89759c9a07e4904c0a061324b5b (patch)
tree29ed3c5f382fdf802ccc20c70225a4730b6246b3 /container-onnxruntime
parent83114f71b32dc468dc7461963cc67dfb0ce0dea9 (diff)
standalone container does not really need native onnxruntime
Diffstat (limited to 'container-onnxruntime')
-rw-r--r--container-onnxruntime/src/main/java/ai/vespa/onnxruntime/OnnxBundleActivator.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/container-onnxruntime/src/main/java/ai/vespa/onnxruntime/OnnxBundleActivator.java b/container-onnxruntime/src/main/java/ai/vespa/onnxruntime/OnnxBundleActivator.java
index 66dbed98073..81eff2be250 100644
--- a/container-onnxruntime/src/main/java/ai/vespa/onnxruntime/OnnxBundleActivator.java
+++ b/container-onnxruntime/src/main/java/ai/vespa/onnxruntime/OnnxBundleActivator.java
@@ -23,18 +23,24 @@ public class OnnxBundleActivator implements BundleActivator {
@Override
public void start(BundleContext ctx) {
+ String skipAll = OnnxBundleActivator.class.getSimpleName() + SKIP_SUFFIX;
+ if (SKIP_VALUE.equals(System.getProperty(skipAll))) {
+ log.info("skip loading of native libraries");
+ return;
+ }
for (String libName : LIBRARY_NAMES) {
String skipProp = SKIP_PREFIX + libName + SKIP_SUFFIX;
if (SKIP_VALUE.equals(System.getProperty(skipProp))) {
- log.info("already loaded native library "+libName+", skipping");
+ log.fine("already loaded native library "+libName+", skipping");
} else {
- System.setProperty(skipProp, SKIP_VALUE);
- log.info("loading native library: "+libName);
+ log.fine("loading native library: "+libName);
try {
System.loadLibrary(libName);
- log.fine("loaded native library OK: "+libName);
+ // this property also signals onnxruntime to skip loading:
+ System.setProperty(skipProp, SKIP_VALUE);
+ log.info("loaded native library OK: "+libName);
} catch (Exception|UnsatisfiedLinkError e) {
- log.warning("Could not load native library '"+libName+"' because: "+e.getMessage());
+ log.info("Could not load native library '"+libName+"' because: "+e.getMessage());
}
}
}
@@ -46,8 +52,10 @@ public class OnnxBundleActivator implements BundleActivator {
// but this should in theory do the necessary thing.
for (String libName : LIBRARY_NAMES) {
String skipProp = SKIP_PREFIX + libName + SKIP_SUFFIX;
+ if (SKIP_VALUE.equals(System.getProperty(skipProp))) {
+ log.info("will unload native library: "+libName);
+ }
System.clearProperty(skipProp);
- log.info("will unload native library: "+libName);
}
}
}