| | #!/bin/bash |
| | set -e |
| | |
| | echo "Updating system packages..." |
| | sudo apt update && sudo apt upgrade -y |
| | |
| | echo "Installing system dependencies..." |
| | sudo apt install vim ffmpeg libsndfile1 git htop git-lfs -y |
| |
|
| | |
| | echo "Installing Python 3.10..." |
| | sudo apt install python3.10 python3.10-venv -y |
| |
|
| | |
| | if ! command -v python3.10 &> /dev/null; then |
| | echo "Failed to install Python 3.10. Please check your system and try again." |
| | exit 1 |
| | fi |
| |
|
| | |
| | PYTHON_VERSION=$(python3.10 --version | awk '{print $2}') |
| | echo "Using Python version: ${PYTHON_VERSION}" |
| |
|
| | |
| | if command -v nvidia-smi &> /dev/null; then |
| | echo "NVIDIA GPU detected. Will install CUDA-enabled PyTorch." |
| | CUDA_AVAILABLE=1 |
| | CUDA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | head -n 1) |
| | echo "CUDA Driver Version: ${CUDA_VERSION}" |
| | else |
| | echo "No NVIDIA GPU detected. Will install CPU-only PyTorch." |
| | CUDA_AVAILABLE=0 |
| | fi |
| |
|
| | |
| | if [ ! -d "venv" ]; then |
| | echo "Creating Python virtual environment..." |
| | python3.10 -m venv venv |
| | else |
| | echo "Virtual environment already exists." |
| | fi |
| |
|
| | |
| | source venv/bin/activate |
| |
|
| | |
| | echo "Upgrading pip..." |
| | pip install --upgrade pip |
| |
|
| | |
| | if [ "$CUDA_AVAILABLE" -eq 1 ]; then |
| | CUDA_VERSION_NUM=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | head -n 1 | cut -d'.' -f1) |
| | |
| | if [ "$CUDA_VERSION_NUM" -ge 535 ]; then |
| | PYTORCH_CUDA="cu124" |
| | elif [ "$CUDA_VERSION_NUM" -ge 530 ]; then |
| | PYTORCH_CUDA="cu121" |
| | elif [ "$CUDA_VERSION_NUM" -ge 520 ]; then |
| | PYTORCH_CUDA="cu118" |
| | elif [ "$CUDA_VERSION_NUM" -ge 510 ]; then |
| | PYTORCH_CUDA="cu117" |
| | else |
| | echo "Warning: CUDA version may be too old. Defaulting to CPU version." |
| | CUDA_AVAILABLE=0 |
| | fi |
| | fi |
| |
|
| | |
| | echo "Installing PyTorch 2.6.0..." |
| | if [ "$CUDA_AVAILABLE" -eq 1 ]; then |
| | echo "Installing PyTorch with CUDA support (${PYTORCH_CUDA})..." |
| | pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/${PYTORCH_CUDA} |
| | else |
| | echo "Installing CPU-only PyTorch..." |
| | pip install torch==2.6.0 |
| | fi |
| |
|
| | |
| | echo "Installing Hugging Face CLI and tools..." |
| | pip install huggingface_hub |
| |
|
| | |
| | echo "Verifying installation..." |
| | python -c "import torch; print('PyTorch version:', torch.__version__); print('CUDA available:', torch.cuda.is_available())" |
| |
|
| | |
| | python -c "import huggingface_hub; print('Hugging Face Hub version:', huggingface_hub.__version__)" |
| |
|
| | echo "============================================================" |
| | echo "Setup complete!" |
| | echo "To activate this environment, run:" |
| | echo "source venv/bin/activate" |
| | echo "============================================================" |
| |
|