Skip to content

Commit d4da7c1

Browse files
juntaoclaude
andcommitted
Detect CUDA in bootstrap.sh and download appropriate release binary
On linux-x86_64, check for nvidia-smi, nvcc, or /usr/local/cuda to decide between the CPU and CUDA release variants. Match the correct libtorch (CPU vs CUDA 12.8) accordingly. Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7e2b9c6 commit d4da7c1

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

skills/bootstrap.sh

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# Bootstrap script for Qwen3 ASR skill
3-
# Downloads platform-specific binary, libtorch (Linux only), and models
3+
# Downloads platform-specific binary, libtorch (Linux only), and model
44

55
set -e
66

@@ -33,12 +33,30 @@ detect_platform() {
3333
echo "${os}-${arch}"
3434
}
3535

36+
detect_cuda() {
37+
# Check for NVIDIA GPU and CUDA toolkit
38+
if command -v nvidia-smi &>/dev/null && nvidia-smi &>/dev/null; then
39+
return 0
40+
fi
41+
if command -v nvcc &>/dev/null; then
42+
return 0
43+
fi
44+
if [ -d "/usr/local/cuda" ]; then
45+
return 0
46+
fi
47+
return 1
48+
}
49+
3650
get_asset_name() {
3751
local platform="$1"
3852

3953
case "$platform" in
4054
linux-x86_64)
41-
echo "asr-linux-x86_64"
55+
if detect_cuda; then
56+
echo "asr-linux-x86_64-cuda"
57+
else
58+
echo "asr-linux-x86_64"
59+
fi
4260
;;
4361
linux-aarch64)
4462
echo "asr-linux-aarch64"
@@ -89,6 +107,7 @@ download_binary() {
89107

90108
download_libtorch() {
91109
local platform="$1"
110+
local asset_name="$2"
92111

93112
# macOS uses MLX backend — no libtorch needed
94113
if [[ "$platform" == darwin-* ]]; then
@@ -101,17 +120,21 @@ download_libtorch() {
101120
local libtorch_url=""
102121
local archive_name=""
103122

104-
case "$platform" in
105-
linux-x86_64)
123+
case "$asset_name" in
124+
asr-linux-x86_64)
106125
libtorch_url="https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip"
107126
archive_name="libtorch.zip"
108127
;;
109-
linux-aarch64)
128+
asr-linux-x86_64-cuda)
129+
libtorch_url="https://download.pytorch.org/libtorch/cu128/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcu128.zip"
130+
archive_name="libtorch.zip"
131+
;;
132+
asr-linux-aarch64)
110133
libtorch_url="https://github.com/second-state/libtorch-releases/releases/download/v2.7.1/libtorch-cxx11-abi-aarch64-2.7.1.tar.gz"
111134
archive_name="libtorch.tar.gz"
112135
;;
113136
*)
114-
echo "Error: No libtorch URL for platform ${platform}" >&2
137+
echo "Error: No libtorch URL for asset ${asset_name}" >&2
115138
exit 1
116139
;;
117140
esac
@@ -181,7 +204,7 @@ main() {
181204
echo "Asset: ${asset_name}" >&2
182205

183206
download_binary "$asset_name"
184-
download_libtorch "$platform"
207+
download_libtorch "$platform" "$asset_name"
185208
download_models
186209

187210
echo "" >&2

0 commit comments

Comments
 (0)