forked from jakovius/voxd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_gpu.sh
More file actions
executable file
·118 lines (106 loc) · 3.91 KB
/
check_gpu.sh
File metadata and controls
executable file
·118 lines (106 loc) · 3.91 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
#!/usr/bin/env bash
# Quick GPU acceleration check for whisper-cli
# Checks the actual installed binary, not build configuration
echo "=== GPU Acceleration Check for whisper-cli ==="
echo ""
# Find whisper-cli binary
WHISPER_BIN=""
if command -v whisper-cli >/dev/null 2>&1; then
WHISPER_BIN="$(command -v whisper-cli)"
WHISPER_BIN="$(readlink -f "$WHISPER_BIN" 2>/dev/null || echo "$WHISPER_BIN")"
elif [[ -f "$HOME/.local/bin/whisper-cli" ]]; then
WHISPER_BIN="$HOME/.local/bin/whisper-cli"
elif [[ -f whisper.cpp/build/bin/whisper-cli ]]; then
WHISPER_BIN="whisper.cpp/build/bin/whisper-cli"
fi
if [[ -z "$WHISPER_BIN" ]] || [[ ! -f "$WHISPER_BIN" ]]; then
echo "✗ Error: whisper-cli binary not found"
echo " Please run ./setup.sh first"
exit 1
fi
echo "1. Binary Location:"
echo " $WHISPER_BIN"
echo ""
# Check 1: Linked libraries (most reliable indicator)
echo "2. Linked GPU Libraries:"
GPU_DETECTED=""
GPU_BACKEND=""
if ldd "$WHISPER_BIN" 2>/dev/null | grep -qi "libOpenCL"; then
echo " ✓ OpenCL library: LINKED"
GPU_DETECTED="yes"
GPU_BACKEND="OpenCL"
elif ldd "$WHISPER_BIN" 2>/dev/null | grep -qi "libcuda\|libcudart"; then
echo " ✓ CUDA library: LINKED"
GPU_DETECTED="yes"
GPU_BACKEND="CUDA"
elif ldd "$WHISPER_BIN" 2>/dev/null | grep -qi "libvulkan"; then
echo " ✓ Vulkan library: LINKED"
GPU_DETECTED="yes"
GPU_BACKEND="Vulkan"
else
echo " ✗ No GPU libraries linked (CPU-only build)"
GPU_DETECTED="no"
fi
echo ""
# Check 2: Runtime test - try to run whisper-cli and check output
echo "3. Runtime Test:"
MODEL_PATH="${XDG_DATA_HOME:-$HOME/.local/share}/voxd/models/ggml-base.en.bin"
if [[ ! -f "$MODEL_PATH" ]]; then
echo " ⚠ Model not found at $MODEL_PATH"
echo " Skipping runtime test (model required)"
else
echo " Testing with model: $MODEL_PATH"
echo " Running: whisper-cli -m \"$MODEL_PATH\" -f /dev/null"
echo ""
# Capture output and check for GPU-related messages
OUTPUT=$(timeout 10s "$WHISPER_BIN" -m "$MODEL_PATH" -f /dev/null 2>&1 || true)
# Check for GPU-related output
if echo "$OUTPUT" | grep -qiE "(ggml.*opencl|using.*opencl|opencl.*device|ggml.*cuda|using.*cuda|cuda.*device|ggml.*vulkan|using.*vulkan|vulkan.*device)"; then
echo " ✓ GPU backend detected in runtime output"
if [[ -z "$GPU_BACKEND" ]]; then
# Try to determine backend from output
if echo "$OUTPUT" | grep -qi "opencl"; then
GPU_BACKEND="OpenCL"
elif echo "$OUTPUT" | grep -qi "cuda"; then
GPU_BACKEND="CUDA"
elif echo "$OUTPUT" | grep -qi "vulkan"; then
GPU_BACKEND="Vulkan"
fi
fi
GPU_DETECTED="yes"
elif echo "$OUTPUT" | grep -qiE "(error.*gpu|gpu.*error|gpu.*not.*available|no.*gpu)"; then
echo " ✗ GPU error detected (GPU may not be working properly)"
GPU_DETECTED="error"
else
echo " ✗ No GPU messages in output (likely CPU-only)"
if [[ "$GPU_DETECTED" == "yes" ]]; then
echo " ⚠ Warning: GPU libraries are linked but not used at runtime"
fi
fi
# Show first few lines of output for debugging
echo ""
echo " Output preview:"
echo "$OUTPUT" | head -10 | sed 's/^/ /'
fi
echo ""
echo "=== Summary ==="
if [[ "$GPU_DETECTED" == "yes" ]]; then
echo "✓ GPU acceleration: ENABLED"
if [[ -n "$GPU_BACKEND" ]]; then
echo " Backend: $GPU_BACKEND"
fi
echo " Binary: $WHISPER_BIN"
echo ""
echo " To verify it's working: Run a transcription and monitor GPU usage"
echo " (e.g., with 'watch -n 1 intel_gpu_top' for Intel or 'nvidia-smi' for NVIDIA)"
elif [[ "$GPU_DETECTED" == "error" ]]; then
echo "✗ GPU acceleration: ERROR"
echo " GPU libraries are present but not working properly"
echo " Check GPU drivers and runtime libraries"
else
echo "✗ GPU acceleration: DISABLED (CPU-only build)"
echo ""
echo " To enable GPU acceleration:"
echo " 1. Ensure GPU drivers are installed"
echo " 2. Run: VOXD_FORCE_GPU_REBUILD=1 ./setup.sh"
fi