From 521bb62f1098a0308a43a2e255234daa630278f0 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 11 Sep 2024 16:55:20 -0700 Subject: [PATCH] openvino: better gpu failure fallback --- plugins/openvino/package-lock.json | 4 ++-- plugins/openvino/package.json | 2 +- plugins/openvino/src/ov/__init__.py | 36 ++++++++++++++++------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/plugins/openvino/package-lock.json b/plugins/openvino/package-lock.json index 7bffdbfafc..e074f18031 100644 --- a/plugins/openvino/package-lock.json +++ b/plugins/openvino/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/openvino", - "version": "0.1.115", + "version": "0.1.116", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/openvino", - "version": "0.1.115", + "version": "0.1.116", "devDependencies": { "@scrypted/sdk": "file:../../sdk" } diff --git a/plugins/openvino/package.json b/plugins/openvino/package.json index b5ffd6d027..4e11dad734 100644 --- a/plugins/openvino/package.json +++ b/plugins/openvino/package.json @@ -42,5 +42,5 @@ "devDependencies": { "@scrypted/sdk": "file:../../sdk" }, - "version": "0.1.115" + "version": "0.1.116" } diff --git a/plugins/openvino/src/ov/__init__.py b/plugins/openvino/src/ov/__init__.py index fd76e3c247..da385b4021 100644 --- a/plugins/openvino/src/ov/__init__.py +++ b/plugins/openvino/src/ov/__init__.py @@ -165,8 +165,6 @@ def __init__(self, nativeId: str | None = None): self.sigmoid = model == "yolo-v4-tiny-tf" self.modelName = model - print(f"model/mode/precision: {model}/{mode}/{precision}") - ovmodel = "best" if self.scrypted_model else model model_version = "v5" @@ -203,22 +201,28 @@ def __init__(self, nativeId: str | None = None): try: self.compiled_model = self.core.compile_model(xmlFile, mode) - print( - "EXECUTION_DEVICES", - self.compiled_model.get_property("EXECUTION_DEVICES"), - ) except: - import traceback - - traceback.print_exc() - print("Reverting all settings.") - self.storage.removeItem("mode") - self.storage.removeItem("model") - self.storage.removeItem("precision") if mode == "GPU": - print("GPU mode failed, reverting to AUTO.") - self.storage.setItem("mode", "AUTO") - self.requestRestart() + try: + print("GPU mode failed, reverting to AUTO.") + mode = "AUTO" + self.mode = mode + self.compiled_model = self.core.compile_model(xmlFile, mode) + except: + import traceback + + traceback.print_exc() + print("Reverting all settings.") + self.storage.removeItem("mode") + self.storage.removeItem("model") + self.storage.removeItem("precision") + self.requestRestart() + + print( + "EXECUTION_DEVICES", + self.compiled_model.get_property("EXECUTION_DEVICES"), + ) + print(f"model/mode/precision: {model}/{mode}/{precision}") # mobilenet 1,300,300,3 # yolov3/4 1,416,416,3