Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 3211173

Browse files
authored
Add AVX support for Linux in install.sh (#486)
1 parent 88105b0 commit 3211173

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

install.sh

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ check_install_jq_tar() {
3939
fi
4040
}
4141

42+
determine_avx_support() {
43+
if grep -q avx512 /proc/cpuinfo; then
44+
echo "-avx512"
45+
elif grep -q avx2 /proc/cpuinfo; then
46+
echo "-avx2"
47+
elif grep -q avx /proc/cpuinfo; then
48+
echo "-avx"
49+
else
50+
echo ""
51+
fi
52+
}
53+
4254
# Function to download and install nitro
4355
install_nitro() {
4456
rm -rf /tmp/nitro
@@ -73,8 +85,10 @@ create_uninstall_script() {
7385

7486
# Determine OS and architecture
7587
OS=$(uname -s)
88+
ARCH=$(uname -m)
7689
VERSION="latest"
7790
GPU=""
91+
AVX=""
7892

7993
check_install_jq_tar
8094

@@ -91,6 +105,18 @@ do
91105
shift
92106
shift
93107
;;
108+
--avx)
109+
AVX="-avx"
110+
shift
111+
;;
112+
--avx2)
113+
AVX="-avx2"
114+
shift
115+
;;
116+
--avx512)
117+
AVX="-avx512"
118+
shift
119+
;;
94120
esac
95121
done
96122

@@ -126,7 +152,10 @@ fi
126152
# Construct download URL based on OS, ARCH, GPU and VERSION
127153
case $OS in
128154
Linux)
129-
FILE_NAME="nitro-${VERSION}-linux-amd64${GPU}${CUDA_VERSION}.tar.gz"
155+
if [ -z "$AVX" ]; then
156+
AVX=$(determine_avx_support)
157+
fi
158+
FILE_NAME="nitro-${VERSION}-linux-amd64${AVX}${GPU}${CUDA_VERSION}.tar.gz"
130159
;;
131160
Darwin)
132161
ARCH_FORMAT="mac-universal"
@@ -140,6 +169,16 @@ esac
140169

141170
DOWNLOAD_URL="https://github.com/janhq/nitro/releases/download/v${VERSION}/${FILE_NAME}"
142171

172+
# Check AVX support
173+
if [ -z "$AVX" ] && [ "$OS" == "Linux" ]; then
174+
echo "AVX is not supported on this system."
175+
exit 1
176+
fi
177+
178+
# Remove existing Nitro installation
179+
echo "Removing existing Nitro installation..."
180+
rm -rf /usr/local/bin/nitro
181+
143182
# Download, install, and create uninstall script
144183
install_nitro "$DOWNLOAD_URL"
145184
create_uninstall_script

0 commit comments

Comments
 (0)