openvino/lxc: fix crashing

This commit is contained in:
Koushik Dutta
2024-09-12 10:49:18 -07:00
parent 521bb62f10
commit c42b8ecda2
7 changed files with 56 additions and 41 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/core",
"version": "0.3.70",
"version": "0.3.71",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/core",
"version": "0.3.70",
"version": "0.3.71",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/core",
"version": "0.3.70",
"version": "0.3.71",
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -1,8 +1,8 @@
import fs from 'fs';
import sdk from '@scrypted/sdk';
import child_process from 'child_process';
import { once } from 'events';
import sdk from '@scrypted/sdk';
import { stdout } from 'process';
import fs from 'fs';
import os from 'os';
export const SCRYPTED_INSTALL_ENVIRONMENT_LXC = 'lxc';
@@ -42,12 +42,52 @@ export async function checkLxcDependencies() {
sdk.log.a('Failed to daemon-reload systemd.');
}
try {
const output = await new Promise<string>((r, f) => child_process.exec("sh -c 'apt show versions level-zero'", (err, stdout, stderr) => {
if (err && !stdout && !stderr)
f(err);
else
r(stdout + '\n' + stderr);
}));
const cpuModel = os.cpus()[0].model;
if (cpuModel.includes('Core') && cpuModel.includes('Ultra')) {
if (
// apt
output.includes('No packages found')
) {
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-npu.sh | bash']);
const [exitCode] = await once(cp, 'exit');
if (exitCode !== 0)
sdk.log.a('Failed to install intel-driver-compiler-npu.');
else
needRestart = true;
}
}
else {
// level-zero crashes openvino on older CPU due to illegal instruction.
// so ensure it is not installed if this is not a core ultra system with npu.
if (
// apt
!output.includes('No packages found')
) {
const cp = child_process.spawn('apt', ['-y', 'remove', 'level-zero']);
const [exitCode] = await once(cp, 'exit');
console.log('level-zero removed', exitCode);
}
}
}
catch (e) {
sdk.log.a('Failed to verify/install intel-driver-compiler-npu.');
}
try {
// intel opencl icd is broken from their official apt repos on kernel versions 6.8, which ships with ubuntu 24.04 and proxmox 8.2.
// the intel apt repo has not been updated yet.
// the current workaround is to install the release manually.
// https://github.com/intel/compute-runtime/releases/tag/24.13.29138.7
const output = await new Promise<string>((r,f)=> child_process.exec("sh -c 'apt show versions intel-opencl-icd'", (err, stdout, stderr) => {
const output = await new Promise<string>((r, f) => child_process.exec("sh -c 'apt show versions intel-opencl-icd'", (err, stdout, stderr) => {
if (err && !stdout && !stderr)
f(err);
else
@@ -60,7 +100,7 @@ export async function checkLxcDependencies() {
// was installed via script at some point
|| output.includes('Version: 24.13.29138.7')
// current script version: 24.17.29377.6
) {
) {
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-graphics.sh | bash']);
const [exitCode] = await once(cp, 'exit');
if (exitCode !== 0)
@@ -73,30 +113,6 @@ export async function checkLxcDependencies() {
sdk.log.a('Failed to verify/install intel-opencl-icd version.');
}
try {
const output = await new Promise<string>((r,f)=> child_process.exec("sh -c 'apt show versions intel-driver-compiler-npu'", (err, stdout, stderr) => {
if (err && !stdout && !stderr)
f(err);
else
r(stdout + '\n' + stderr);
}));
if (
// apt
output.includes('No packages found')
) {
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-npu.sh | bash']);
const [exitCode] = await once(cp, 'exit');
if (exitCode !== 0)
sdk.log.a('Failed to install intel-driver-compiler-npu.');
else
needRestart = true;
}
}
catch (e) {
sdk.log.a('Failed to verify/install intel-driver-compiler-npu.');
}
if (needRestart)
sdk.log.a('A system update is pending. Please restart Scrypted to apply changes.');
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/openvino",
"version": "0.1.116",
"version": "0.1.117",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/openvino",
"version": "0.1.116",
"version": "0.1.117",
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
}

View File

@@ -42,5 +42,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.116"
"version": "0.1.117"
}

View File

@@ -202,6 +202,9 @@ class OpenVINOPlugin(
try:
self.compiled_model = self.core.compile_model(xmlFile, mode)
except:
import traceback
traceback.print_exc()
if mode == "GPU":
try:
print("GPU mode failed, reverting to AUTO.")
@@ -209,9 +212,6 @@ class OpenVINOPlugin(
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")

View File

@@ -1,8 +1,7 @@
# must ensure numpy is pinned to prevent dependencies with an unpinned numpy from pulling numpy>=2.0.
numpy==1.26.4
# openvino 2024.3.0 crashes on older CPU
# openvino 2024.2.0 crashes on current CPU.
# older versions unsure about NPU support.
# openvino 2024.3.0 crashes on older CPU (J4105 and older) if level-zero is installed via apt.
# openvino 2024.2.0 and older crashes on arc dGPU.
openvino==2024.3.0
Pillow==10.3.0
opencv-python==4.10.0.84