-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall_dependencies.sh
More file actions
executable file
·328 lines (277 loc) · 9.51 KB
/
Copy pathinstall_dependencies.sh
File metadata and controls
executable file
·328 lines (277 loc) · 9.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#!/bin/bash
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
set -euo pipefail
XPU_SMI_RELEASE_URL="https://github.com/intel/xpumanager/releases/download/v1.3.6/xpu-smi_1.3.6_20260206.143628.1004f6cb.u24.04_amd64.deb"
XPU_SMI_DOWNLOAD_FILE="xpu-smi.deb"
# Parse command-line arguments
AUTO_YES=false
AUTO_NO=false
while getopts "yn" opt; do
case $opt in
y)
AUTO_YES=true
;;
n)
AUTO_NO=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
echo "Usage: $0 [-y] [-n]"
echo " -y Auto-accept GPU driver installation (non-interactive mode)"
echo " -n Auto-skip GPU driver installation (non-interactive mode)"
exit 1
;;
esac
done
if [ "$AUTO_YES" = true ] && [ "$AUTO_NO" = true ]; then
echo "Error: -y and -n are mutually exclusive."
exit 1
fi
if [ "$EUID" -eq 0 ]; then
if ! command -v sudo >/dev/null 2>&1; then
sudo() { "$@"; }
fi
fi
if [ -z "${SUDO_USER:-}" ]; then
if [ "$EUID" -eq 0 ]; then
echo "Warning: SUDO_USER is not set, but running as root (likely Docker/CI). Proceeding..."
else
echo "Error: SUDO_USER is not set. Please run this script with sudo from a non-root user account."
exit 1
fi
fi
command_exists() {
command -v "$1" >/dev/null 2>&1
}
download_deb_file() {
local url="$1"
local output="$2"
local description="${3:-file}"
echo "Downloading $description..."
# Fail on HTTP errors, follow redirects and be silent about progress
if ! curl -fSL -o "$output" "$url"; then
echo "❌ ERROR: Failed to download $description from $url"
return 1
fi
# Basic validation: ensure the file looks like a .deb (dpkg-deb can read it)
if ! dpkg-deb -I "$output" >/dev/null 2>&1; then
echo "❌ ERROR: Downloaded $description does not appear to be a valid .deb: $output"
rm -f "$output"
return 1
fi
echo "✅ Downloaded and validated $description"
return 0
}
# Dynamic function to install and verify packages
# Usage: install_and_verify_packages "package1 package2 package3" "Package Category Name"
install_and_verify_packages() {
local packages="$1"
local category_name="${2:-packages}"
echo "Installing $category_name..."
# Convert space-separated string to array
local pkg_array
read -ra pkg_array <<< "$packages"
if ! apt update -y; then
echo "❌ ERROR: Failed to update apt package list"
return 1
fi
if ! apt install -y "${pkg_array[@]}"; then
echo "❌ ERROR: Failed to install $category_name"
return 1
fi
# Verify installation
echo "Verifying $category_name installation..."
local missing_packages=()
for pkg in "${pkg_array[@]}"; do
# Check if it's a command-line tool
if command -v "$pkg" >/dev/null 2>&1; then
continue
# Check if it's an installed package
elif dpkg -s "$pkg" >/dev/null 2>&1; then
continue
else
missing_packages+=("$pkg")
fi
done
if [ ${#missing_packages[@]} -gt 0 ]; then
echo "❌ ERROR: The following packages failed to install: ${missing_packages[*]}"
return 1
fi
echo "✅ $category_name installed successfully"
return 0
}
install_system_dependencies() {
local system_packages="curl wget libxml2 git software-properties-common vulkan-tools libportaudio2 unzip"
if ! install_and_verify_packages "$system_packages" "system dependencies"; then
echo "❌ ERROR: Failed to install system dependencies"
exit 1
fi
}
download_espeak_ng() {
if dpkg -s espeak-ng &> /dev/null; then
echo "✅ espeak-ng is already installed."
return 0
fi
local espeak_packages="espeak-ng espeak-ng-data libsndfile1"
if ! install_and_verify_packages "$espeak_packages" "espeak-ng and audio libraries"; then
echo "❌ ERROR: Failed to install espeak-ng packages"
exit 1
fi
# Additional verification that espeak-ng command is available
if ! command -v espeak-ng >/dev/null 2>&1; then
echo "❌ ERROR: espeak-ng command not found after installation"
exit 1
fi
}
install_drivers() {
echo ""
echo "=========================================="
echo "🔧 Driver Installation & Verification"
echo "=========================================="
echo ""
echo "This application requires GPU & NPU drivers to be installed."
echo ""
echo "The installer script will perform 3 steps:"
echo " 1. Check and install Intel GPU drivers"
echo " 2. Check and install Intel NPU drivers"
echo " 3. Verify devices can run on OpenVINO runtime"
echo ""
echo "Additional setup includes:"
echo " • Configure OpenCL runtime"
echo " • Set up necessary permissions"
echo ""
if [ "$AUTO_NO" = true ]; then
echo "Auto-skipping driver installation (-n flag set)."
echo ""
echo "⚠️ Driver installation skipped."
echo ""
echo "You can manually install drivers later by running:"
echo "sudo bash -c \"\$(wget -qLO - https://raw.githubusercontent.com/open-edge-platform/edge-developer-kit-reference-scripts/refs/heads/main/main_installer.sh)\""
echo ""
return 0
elif [ "$AUTO_YES" = false ]; then
read -p "Would you like to download and run the drivers installer script now? (y/N): " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "⚠️ Driver installation skipped."
echo ""
echo "You can manually install drivers later by running:"
echo "sudo bash -c \"\$(wget -qLO - https://raw.githubusercontent.com/open-edge-platform/edge-developer-kit-reference-scripts/refs/heads/main/main_installer.sh)\""
echo ""
return 0
fi
else
echo "Auto-accepting driver installation (-y flag set)..."
fi
echo ""
echo "📥 Downloading driver installer script..."
local driver_script="/tmp/main_installer.sh"
local driver_script_url="https://raw.githubusercontent.com/open-edge-platform/edge-developer-kit-reference-scripts/refs/heads/main/main_installer.sh"
if ! wget -q --show-progress -O "$driver_script" "$driver_script_url"; then
echo "❌ ERROR: Failed to download driver installer script"
echo "Please manually download and run the script from:"
echo " $driver_script_url"
return 1
fi
chmod +x "$driver_script"
echo ""
echo "🚀 Running driver installer script..."
echo "This will perform the following:"
echo " [1/3] Installing GPU drivers..."
echo " [2/3] Installing NPU drivers..."
echo " [3/3] Verifying OpenVINO device compatibility..."
echo ""
echo "This may take several minutes. Please wait..."
echo ""
# Save current directory and change to /tmp
local original_dir
original_dir=$(pwd)
cd /tmp || return 1
if ! "$driver_script"; then
echo ""
echo "❌ ERROR: Driver installation failed"
echo "Please check the error messages above and try again"
rm -f "$driver_script"
cd "$original_dir" || {
echo "❌ ERROR: Failed to return to original directory: $original_dir"
return 1
}
return 1
fi
# Cleanup and return to original directory
rm -f "$driver_script"
cd "$original_dir" || {
echo "❌ ERROR: Failed to return to original directory: $original_dir"
return 1
}
}
# Install XPU-SMI (Intel GPU monitoring tool)
install_xpu_smi() {
echo "XPU-SMI Installation"
if command_exists xpu-smi; then
echo "✅ XPU-SMI is already installed."
return 0
fi
# Download the .deb package
if ! download_deb_file "$XPU_SMI_RELEASE_URL" "$XPU_SMI_DOWNLOAD_FILE" "XPU-SMI package"; then
return 1
fi
# Check if we can install system-wide (requires sudo)
if command_exists dpkg && [[ $EUID -eq 0 ]]; then
echo "Installing XPU-SMI system-wide..."
if sudo apt install -y "./$XPU_SMI_DOWNLOAD_FILE"; then
rm -f "$XPU_SMI_DOWNLOAD_FILE"
echo "XPU-SMI installed system-wide."
return 0
else
echo "❌ ERROR: System-wide XPU-SMI installation failed."
echo "Please install manually: sudo apt install ./$XPU_SMI_DOWNLOAD_FILE"
rm -f "$XPU_SMI_DOWNLOAD_FILE"
return 1
fi
elif command_exists dpkg && sudo -n true 2>/dev/null; then
echo "Installing XPU-SMI system-wide..."
if sudo apt install -y "./$XPU_SMI_DOWNLOAD_FILE"; then
rm -f "$XPU_SMI_DOWNLOAD_FILE"
echo "XPU-SMI installed system-wide."
return 0
else
echo "❌ ERROR: System-wide XPU-SMI installation failed."
echo "Please install manually: sudo apt install ./$XPU_SMI_DOWNLOAD_FILE"
rm -f "$XPU_SMI_DOWNLOAD_FILE"
return 1
fi
else
echo "Cannot install system-wide (no sudo access or not on Debian/Ubuntu)"
rm -f "$XPU_SMI_DOWNLOAD_FILE"
return 1
fi
}
main() {
echo "=========================================="
echo "Installing System Dependencies"
echo "=========================================="
echo ""
install_system_dependencies
echo ""
download_espeak_ng
echo ""
install_drivers
echo ""
install_xpu_smi
echo ""
echo "=========================================="
echo "✅ All dependencies installed and verified successfully!"
echo "=========================================="
echo ""
echo "Summary:"
echo " ✅ System dependencies (curl, wget, git, etc.)"
echo " ✅ espeak-ng and audio libraries"
echo " ✅ GPU drivers installed and verified"
echo " ✅ NPU drivers installed and verified"
echo " ✅ OpenVINO runtime compatibility confirmed"
echo ""
}
main