ryugyosoft commited on
Commit
1e962ea
·
verified ·
1 Parent(s): decc0ef

v0.5.0: restore setup.sh / start.sh (they were uploaded empty)

Browse files
Files changed (2) hide show
  1. setup.sh +62 -0
  2. start.sh +33 -0
setup.sh CHANGED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # onw - Ore no NPU ga konna ni ugoku wake nai: install the resident top-bar app (Ubuntu).
3
+ # Installs the system pieces the indicator and the window need (AppIndicator, WebKit; asks for sudo once), creates .venv,
4
+ # installs onw + the tray, adds "onw" to the application list and starts it in the top bar.
5
+ # GNOME shows indicators through the "Ubuntu AppIndicators" extension, which Ubuntu enables by default.
6
+ set -e
7
+ cd "$(dirname "$0")"
8
+ export PYTHONUTF8=1
9
+
10
+ if ! python3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then
11
+ echo "Python 3.10 or newer is needed (Ubuntu 22.04 and later ship it): sudo apt install python3"
12
+ exit 1
13
+ fi
14
+
15
+ need=""
16
+ # the window is a WebKit web view (pywebview): 4.1 on Ubuntu 24.04 and later, 4.0 before
17
+ webkit=gir1.2-webkit2-4.1
18
+ apt-cache show $webkit >/dev/null 2>&1 || webkit=gir1.2-webkit2-4.0
19
+ for p in python3-venv python3-gi gir1.2-ayatanaappindicator3-0.1 $webkit; do
20
+ dpkg -s "$p" >/dev/null 2>&1 || need="$need $p"
21
+ done
22
+ if [ -n "$need" ]; then
23
+ echo "[setup] installing system packages:$need"
24
+ sudo apt-get install -y $need
25
+ fi
26
+
27
+ install_onw() {
28
+ # the bundled pip is fine (a newer pip once failed to install packages that have scripts, so it is not upgraded)
29
+ .venv/bin/python -m pip install --pre -e ".[tray]" \
30
+ --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
31
+ }
32
+ if [ ! -f .venv/installed-tray.txt ] || ! .venv/bin/python -c "import webview" >/dev/null 2>&1; then
33
+ if [ ! -f .venv/bin/python ]; then
34
+ echo "[setup] creating Python environment in .venv ..."
35
+ # system site packages: the GObject bindings for the indicator and WebKit come from apt (python3-gi)
36
+ python3 -m venv --system-site-packages .venv
37
+ fi
38
+ if ! install_onw; then
39
+ echo "[setup] installation failed; rebuilding the Python environment once ..."
40
+ rm -rf .venv
41
+ python3 -m venv --system-site-packages .venv
42
+ install_onw || exit 1
43
+ fi
44
+ echo ok > .venv/installed.txt
45
+ echo ok > .venv/installed-tray.txt
46
+ fi
47
+
48
+ mkdir -p ~/.local/share/applications
49
+ cat > ~/.local/share/applications/onw.desktop <<EOF
50
+ [Desktop Entry]
51
+ Type=Application
52
+ Name=onw
53
+ Comment=LLMs on the Intel NPU (俺のNPUがこんなに動くわけない)
54
+ Exec=$PWD/.venv/bin/python -m onw tray
55
+ Icon=utilities-system-monitor
56
+ Terminal=false
57
+ Categories=Utility;
58
+ EOF
59
+ echo "[setup] application list: onw"
60
+
61
+ echo "[start] onw is starting in the top bar (first model start: download + NPU compile) ..."
62
+ nohup .venv/bin/python -m onw tray >/dev/null 2>&1 &
start.sh CHANGED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # onw - Ore no NPU ga konna ni ugoku wake nai: one-command start (Linux).
3
+ # ./start.sh LFM2-8B-A1B (default, fits 16 GB machines)
4
+ # ./start.sh ryugyosoft/Qwen3.6-35B-A3B-onw any onw model: a Hugging Face repo id or a local folder
5
+ # ./start.sh MODEL --port 8080 --host 0.0.0.0 further options go to "onw serve"
6
+ # First run: creates .venv (~1 GB), downloads the model, compiles it for the NPU. Later runs start in ~20 s.
7
+ # Afterwards: source .venv/bin/activate, then onw serve / onw chat / onw convert.
8
+ # Without the Intel NPU driver everything runs on the CPU (slowly).
9
+ set -e
10
+ cd "$(dirname "$0")"
11
+ export PYTHONUTF8=1
12
+ MODEL="ryugyosoft/LFM2-8B-A1B-onw"
13
+ if [ $# -gt 0 ] && [ "${1#-}" = "$1" ]; then MODEL="$1"; shift; fi
14
+
15
+ if ! python3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)" 2>/dev/null; then
16
+ echo "Python 3.10 or newer is needed (Ubuntu 22.04 and later ship it): sudo apt install python3"
17
+ exit 1
18
+ fi
19
+
20
+ if [ ! -f .venv/installed.txt ]; then
21
+ echo "[setup] creating Python environment in .venv ..."
22
+ if ! python3 -m venv .venv; then
23
+ echo "python3-venv is missing: sudo apt install python3-venv"
24
+ exit 1
25
+ fi
26
+ .venv/bin/python -m pip install -U pip
27
+ .venv/bin/python -m pip install --pre -e . \
28
+ --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
29
+ echo ok > .venv/installed.txt
30
+ fi
31
+
32
+ echo "[start] $MODEL (first time: download + NPU compile, please wait) ..."
33
+ exec .venv/bin/onw serve "$MODEL" --open "$@"