-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·185 lines (150 loc) · 4.46 KB
/
install.sh
File metadata and controls
executable file
·185 lines (150 loc) · 4.46 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
#!/bin/bash
fetch_latest_release() {
local repo_owner="$1"
local repo_name="$2"
echo "Fetching latest release..." >&2
local latest_release_url="https://api.github.com/repos/${repo_owner}/${repo_name}/releases/latest"
local release_data
if ! release_data=$(curl -fsSL "$latest_release_url" 2>&1); then
error "Failed to fetch release information."
echo "Please check your internet connection and try again." >&2
exit 1
fi
if [[ -z "$release_data" ]] || [[ "$release_data" == *"Not Found"* ]]; then
error "No releases found for this repository."
echo "Please visit https://github.com/${repo_owner}/${repo_name}/releases" >&2
exit 1
fi
echo "$release_data"
}
extract_wheel_url() {
local release_data="$1"
local os_tag
local arch_tag
case "$(uname -s)" in
Darwin) os_tag="macosx" ;;
*) os_tag="linux" ;;
esac
case "$(uname -m)" in
arm64|aarch64) arch_tag="arm64\|aarch64" ;;
*) arch_tag="x86_64\|amd64" ;;
esac
python3 -c "
import sys
import json
try:
data = json.loads('''$release_data''')
assets = data.get('assets', [])
os_tag = '$os_tag'
arch_tags = '$arch_tag'.split('\|')
for asset in assets:
name = asset.get('name', '')
if name.endswith('.whl') and os_tag in name and any(a in name for a in arch_tags):
print(asset.get('browser_download_url', ''))
break
except Exception as e:
print('', file=sys.stderr)
"
}
download_and_install_wheel() {
local wheel_url="$1"
local package_name="$2"
local wheel_name
wheel_name=$(basename "$wheel_url")
echo "Latest release: $wheel_name"
success "Found latest release"
local tmp_dir
tmp_dir=$(mktemp -d)
# shellcheck disable=SC2064
trap "rm -rf '$tmp_dir'" EXIT
echo ""
echo "Downloading wheel..."
local wheel_path="$tmp_dir/$wheel_name"
if ! curl -fsSL "$wheel_url" -o "$wheel_path"; then
error "Failed to download wheel."
exit 1
fi
success "Downloaded wheel"
if ! uv pip install "$wheel_path"; then
error "Failed to install ${package_name}."
exit 1
fi
success "Installed ${package_name}"
}
install_system_vulkan_deps() {
if is_macos; then
install_kosmickrisp
fi
}
main() {
set -eu -o pipefail
local repo_owner="ericcurtin"
local repo_name="vllm-vulkan"
local package_name="vllm-vulkan"
local local_lib=""
if [[ -n "${BASH_SOURCE[0]:-}" ]]; then
local script_dir
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-}")" && pwd)"
local_lib="$script_dir/scripts/lib.sh"
fi
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
# shellcheck source=/dev/null
source "$local_lib"
else
local lib_url="https://raw.githubusercontent.com/$repo_owner/$repo_name/main/scripts/lib.sh"
local lib_tmp
lib_tmp=$(mktemp)
if ! curl -fsSL "$lib_url" -o "$lib_tmp"; then
echo "Error: Failed to fetch lib.sh from $lib_url" >&2
rm -f "$lib_tmp"
exit 1
fi
# shellcheck source=/dev/null
source "$lib_tmp"
rm -f "$lib_tmp"
fi
install_system_vulkan_deps
if ! ensure_uv; then
exit 1
fi
local venv="$HOME/.venv-vllm-vulkan"
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
venv="$PWD/.venv-vllm-vulkan"
fi
ensure_venv "$venv"
# Install vLLM CPU build (no CUDA dependencies)
local vllm_v
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
vllm_v=$(cat "$(dirname "${BASH_SOURCE[0]}")/.vllm-version")
else
vllm_v=$(curl -fsSL "https://raw.githubusercontent.com/$repo_owner/$repo_name/main/.vllm-version")
fi
local url_base="https://github.com/vllm-project/vllm/releases/download"
local filename="vllm-$vllm_v.tar.gz"
curl -OL "$url_base/v$vllm_v/$filename"
tar xf "$filename"
cd "vllm-$vllm_v"
uv pip install -r requirements/cpu.txt --index-strategy unsafe-best-match --extra-index-url=https://download.pytorch.org/whl/cpu
CXXFLAGS="-Wno-parentheses" uv pip install .
cd -
rm -rf "vllm-$vllm_v"*
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
uv pip install .
else
local release_data
release_data=$(fetch_latest_release "$repo_owner" "$repo_name")
local wheel_url
wheel_url=$(extract_wheel_url "$release_data")
if [[ -z "$wheel_url" ]]; then
error "No wheel file found in the latest release."
exit 1
fi
download_and_install_wheel "$wheel_url" "$package_name"
fi
echo ""
success "Installation complete!"
echo ""
echo "Activate the virtual environment:"
echo " source $venv/bin/activate"
}
main "$@"