Skip to content

Commit

Permalink
openvino/lxc: fix crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Sep 12, 2024
1 parent 521bb62 commit c42b8ec
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 39 deletions.
4 changes: 2 additions & 2 deletions plugins/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
70 changes: 43 additions & 27 deletions plugins/core/src/platform/lxc.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -43,38 +43,51 @@ export async function checkLxcDependencies() {
}

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 level-zero'", (err, stdout, stderr) => {
if (err && !stdout && !stderr)
f(err);
else
r(stdout + '\n' + stderr);
}));

if (
// apt
output.includes('Version: 23')
// was installed via script at some point
|| output.includes('Version: 24.13.29138.7')
// current script version: 24.17.29377.6
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-graphics.sh | bash']);
const [exitCode] = await once(cp, 'exit');
if (exitCode !== 0)
sdk.log.a('Failed to install intel-opencl-icd.');
else
needRestart = true;
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-opencl-icd version.');
sdk.log.a('Failed to verify/install intel-driver-compiler-npu.');
}

try {
const output = await new Promise<string>((r,f)=> child_process.exec("sh -c 'apt show versions intel-driver-compiler-npu'", (err, stdout, stderr) => {
// 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) => {
if (err && !stdout && !stderr)
f(err);
else
Expand All @@ -83,18 +96,21 @@ export async function checkLxcDependencies() {

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']);
output.includes('Version: 23')
// 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)
sdk.log.a('Failed to install intel-driver-compiler-npu.');
sdk.log.a('Failed to install intel-opencl-icd.');
else
needRestart = true;
}
}
catch (e) {
sdk.log.a('Failed to verify/install intel-driver-compiler-npu.');
sdk.log.a('Failed to verify/install intel-opencl-icd version.');
}

if (needRestart)
Expand Down
4 changes: 2 additions & 2 deletions plugins/openvino/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/openvino/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.116"
"version": "0.1.117"
}
6 changes: 3 additions & 3 deletions plugins/openvino/src/ov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ def __init__(self, nativeId: str | None = None):
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.")
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")
Expand Down
5 changes: 2 additions & 3 deletions plugins/openvino/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c42b8ec

Please sign in to comment.