Skip to content

Commit c42b8ec

Browse files
committed
openvino/lxc: fix crashing
1 parent 521bb62 commit c42b8ec

File tree

7 files changed

+54
-39
lines changed

7 files changed

+54
-39
lines changed

plugins/core/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scrypted/core",
3-
"version": "0.3.70",
3+
"version": "0.3.71",
44
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
55
"author": "Scrypted",
66
"license": "Apache-2.0",

plugins/core/src/platform/lxc.ts

+43-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import fs from 'fs';
1+
import sdk from '@scrypted/sdk';
22
import child_process from 'child_process';
33
import { once } from 'events';
4-
import sdk from '@scrypted/sdk';
5-
import { stdout } from 'process';
4+
import fs from 'fs';
5+
import os from 'os';
66

77
export const SCRYPTED_INSTALL_ENVIRONMENT_LXC = 'lxc';
88

@@ -43,38 +43,51 @@ export async function checkLxcDependencies() {
4343
}
4444

4545
try {
46-
// 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.
47-
// the intel apt repo has not been updated yet.
48-
// the current workaround is to install the release manually.
49-
// https://github.com/intel/compute-runtime/releases/tag/24.13.29138.7
50-
const output = await new Promise<string>((r,f)=> child_process.exec("sh -c 'apt show versions intel-opencl-icd'", (err, stdout, stderr) => {
46+
const output = await new Promise<string>((r, f) => child_process.exec("sh -c 'apt show versions level-zero'", (err, stdout, stderr) => {
5147
if (err && !stdout && !stderr)
5248
f(err);
5349
else
5450
r(stdout + '\n' + stderr);
5551
}));
5652

57-
if (
58-
// apt
59-
output.includes('Version: 23')
60-
// was installed via script at some point
61-
|| output.includes('Version: 24.13.29138.7')
62-
// current script version: 24.17.29377.6
53+
const cpuModel = os.cpus()[0].model;
54+
if (cpuModel.includes('Core') && cpuModel.includes('Ultra')) {
55+
if (
56+
// apt
57+
output.includes('No packages found')
6358
) {
64-
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-graphics.sh | bash']);
65-
const [exitCode] = await once(cp, 'exit');
66-
if (exitCode !== 0)
67-
sdk.log.a('Failed to install intel-opencl-icd.');
68-
else
69-
needRestart = true;
59+
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-npu.sh | bash']);
60+
const [exitCode] = await once(cp, 'exit');
61+
if (exitCode !== 0)
62+
sdk.log.a('Failed to install intel-driver-compiler-npu.');
63+
else
64+
needRestart = true;
65+
}
66+
}
67+
else {
68+
// level-zero crashes openvino on older CPU due to illegal instruction.
69+
// so ensure it is not installed if this is not a core ultra system with npu.
70+
if (
71+
// apt
72+
!output.includes('No packages found')
73+
) {
74+
const cp = child_process.spawn('apt', ['-y', 'remove', 'level-zero']);
75+
const [exitCode] = await once(cp, 'exit');
76+
console.log('level-zero removed', exitCode);
77+
}
7078
}
79+
7180
}
7281
catch (e) {
73-
sdk.log.a('Failed to verify/install intel-opencl-icd version.');
82+
sdk.log.a('Failed to verify/install intel-driver-compiler-npu.');
7483
}
7584

7685
try {
77-
const output = await new Promise<string>((r,f)=> child_process.exec("sh -c 'apt show versions intel-driver-compiler-npu'", (err, stdout, stderr) => {
86+
// 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.
87+
// the intel apt repo has not been updated yet.
88+
// the current workaround is to install the release manually.
89+
// https://github.com/intel/compute-runtime/releases/tag/24.13.29138.7
90+
const output = await new Promise<string>((r, f) => child_process.exec("sh -c 'apt show versions intel-opencl-icd'", (err, stdout, stderr) => {
7891
if (err && !stdout && !stderr)
7992
f(err);
8093
else
@@ -83,18 +96,21 @@ export async function checkLxcDependencies() {
8396

8497
if (
8598
// apt
86-
output.includes('No packages found')
87-
) {
88-
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-npu.sh | bash']);
99+
output.includes('Version: 23')
100+
// was installed via script at some point
101+
|| output.includes('Version: 24.13.29138.7')
102+
// current script version: 24.17.29377.6
103+
) {
104+
const cp = child_process.spawn('sh', ['-c', 'curl https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-intel-graphics.sh | bash']);
89105
const [exitCode] = await once(cp, 'exit');
90106
if (exitCode !== 0)
91-
sdk.log.a('Failed to install intel-driver-compiler-npu.');
107+
sdk.log.a('Failed to install intel-opencl-icd.');
92108
else
93109
needRestart = true;
94110
}
95111
}
96112
catch (e) {
97-
sdk.log.a('Failed to verify/install intel-driver-compiler-npu.');
113+
sdk.log.a('Failed to verify/install intel-opencl-icd version.');
98114
}
99115

100116
if (needRestart)

plugins/openvino/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/openvino/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242
"devDependencies": {
4343
"@scrypted/sdk": "file:../../sdk"
4444
},
45-
"version": "0.1.116"
45+
"version": "0.1.117"
4646
}

plugins/openvino/src/ov/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ def __init__(self, nativeId: str | None = None):
202202
try:
203203
self.compiled_model = self.core.compile_model(xmlFile, mode)
204204
except:
205+
import traceback
206+
traceback.print_exc()
207+
205208
if mode == "GPU":
206209
try:
207210
print("GPU mode failed, reverting to AUTO.")
208211
mode = "AUTO"
209212
self.mode = mode
210213
self.compiled_model = self.core.compile_model(xmlFile, mode)
211214
except:
212-
import traceback
213-
214-
traceback.print_exc()
215215
print("Reverting all settings.")
216216
self.storage.removeItem("mode")
217217
self.storage.removeItem("model")

plugins/openvino/src/requirements.txt

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

0 commit comments

Comments
 (0)