2025-10-24 11:22:56 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2026-02-14 21:34:16 +03:00
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Function to clean up on error
|
|
|
|
|
cleanup() {
|
|
|
|
|
echo "Cleaning up temporary files..."
|
|
|
|
|
rm -f "$deb_file"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trap cleanup ERR
|
|
|
|
|
trap 'echo "Script interrupted by user (Ctrl+C)"; cleanup; exit 130' INT
|
|
|
|
|
|
2025-10-24 11:22:56 +03:00
|
|
|
# Update package list and install dependencies
|
2026-02-14 21:34:16 +03:00
|
|
|
echo "Updating package list and installing dependencies..."
|
2025-10-24 11:22:56 +03:00
|
|
|
sudo apt-get update
|
|
|
|
|
sudo apt-get install -y build-essential cmake git wget pciutils kmod udev
|
|
|
|
|
|
|
|
|
|
# Check if gcc-12 is needed
|
2026-02-14 21:34:16 +03:00
|
|
|
echo "Checking GCC version..."
|
2025-10-24 11:22:56 +03:00
|
|
|
current_gcc_version=$(gcc --version | head -n1 | awk '{print $NF}')
|
2026-02-14 21:34:16 +03:00
|
|
|
if ! dpkg --compare-versions "$current_gcc_version" ge "12" 2>/dev/null; then
|
2025-10-24 11:22:56 +03:00
|
|
|
echo "Current GCC version ($current_gcc_version) is lower than 12, installing gcc-12..."
|
|
|
|
|
sudo apt-get install -y gcc-12
|
|
|
|
|
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
|
|
|
|
|
echo "GCC-12 installed and set as default"
|
|
|
|
|
else
|
|
|
|
|
echo "Current GCC version ($current_gcc_version) is sufficient, skipping GCC installation"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Determine architecture
|
2026-02-14 21:34:16 +03:00
|
|
|
echo "Determining system architecture..."
|
2025-10-24 11:22:56 +03:00
|
|
|
arch=$(uname -m)
|
|
|
|
|
download_url=""
|
|
|
|
|
|
|
|
|
|
if [[ $arch == "x86_64" ]]; then
|
2026-02-14 21:34:16 +03:00
|
|
|
download_url="https://github.com/ivanshi1108/assets/releases/download/v0.17/axcl_host_x86_64_V3.10.2_20251111020143_NO5046.deb"
|
|
|
|
|
deb_file="axcl.deb"
|
2025-10-24 11:22:56 +03:00
|
|
|
elif [[ $arch == "aarch64" ]]; then
|
2026-02-14 21:34:16 +03:00
|
|
|
download_url="https://github.com/ivanshi1108/assets/releases/download/v0.17/axcl_host_aarch64_V3.10.2_20251111020143_NO5046.deb"
|
|
|
|
|
deb_file="axcl.deb"
|
2025-10-24 11:22:56 +03:00
|
|
|
else
|
|
|
|
|
echo "Unsupported architecture: $arch"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2026-02-14 21:34:16 +03:00
|
|
|
# Check for required Linux headers before downloading
|
|
|
|
|
echo "Checking for required Linux headers..."
|
|
|
|
|
kernel_version=$(uname -r)
|
|
|
|
|
if dpkg -l | grep -q "linux-headers-${kernel_version}" || [ -d "/lib/modules/${kernel_version}/build" ]; then
|
|
|
|
|
echo "Linux headers or kernel modules directory found for kernel ${kernel_version}/build."
|
|
|
|
|
else
|
|
|
|
|
echo "Linux headers for kernel ${kernel_version} not found. Please install them first: sudo apt-get install linux-headers-${kernel_version}"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-24 11:22:56 +03:00
|
|
|
# Download AXCL driver
|
|
|
|
|
echo "Downloading AXCL driver for $arch..."
|
2026-02-14 21:34:16 +03:00
|
|
|
wget --timeout=30 --tries=3 "$download_url" -O "$deb_file"
|
2025-10-24 11:22:56 +03:00
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
2026-02-14 21:34:16 +03:00
|
|
|
echo "Failed to download AXCL driver after retries"
|
2025-10-24 11:22:56 +03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Install AXCL driver
|
|
|
|
|
echo "Installing AXCL driver..."
|
|
|
|
|
sudo dpkg -i "$deb_file"
|
|
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "Failed to install AXCL driver, attempting to fix dependencies..."
|
|
|
|
|
sudo apt-get install -f -y
|
|
|
|
|
sudo dpkg -i "$deb_file"
|
|
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
2026-02-14 21:34:16 +03:00
|
|
|
echo "AXCL driver installation failed after dependency fix"
|
2025-10-24 11:22:56 +03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Update environment
|
|
|
|
|
echo "Updating environment..."
|
|
|
|
|
source /etc/profile
|
|
|
|
|
|
|
|
|
|
# Verify installation
|
|
|
|
|
echo "Verifying AXCL installation..."
|
|
|
|
|
if command -v axcl-smi &> /dev/null; then
|
|
|
|
|
echo "AXCL driver detected, checking AI accelerator status..."
|
|
|
|
|
|
|
|
|
|
axcl_output=$(axcl-smi 2>&1)
|
|
|
|
|
axcl_exit_code=$?
|
|
|
|
|
|
|
|
|
|
echo "$axcl_output"
|
|
|
|
|
|
|
|
|
|
if [ $axcl_exit_code -eq 0 ]; then
|
|
|
|
|
echo "AXCL driver installation completed successfully!"
|
|
|
|
|
else
|
|
|
|
|
echo "AXCL driver installed but no AI accelerator detected or communication failed."
|
|
|
|
|
echo "Please check if the AI accelerator is properly connected and powered on."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "axcl-smi command not found. AXCL driver installation may have failed."
|
|
|
|
|
exit 1
|
2026-02-14 21:34:16 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
|
echo "Cleaning up temporary files..."
|
|
|
|
|
rm -f "$deb_file"
|
|
|
|
|
echo "Installation script completed."
|