-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUbuntuROCm9060XTSetup.sh
More file actions
75 lines (57 loc) · 2.95 KB
/
UbuntuROCm9060XTSetup.sh
File metadata and controls
75 lines (57 loc) · 2.95 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
#!/bin/bash
# ==============================================================================
# 2026 Comprehensive AI Setup for Ubuntu + AMD RDNA 4 (RX 9060 XT)
# Target Architecture: gfx1200 | Target Kernel: 6.18+ | ROCm: 7.2.0
# ==============================================================================
set -e # Exit on error
echo "🚀 Starting 2026 AMD AI Environment Deployment..."
# 1. Update System & Install Dependencies
sudo apt update && sudo apt upgrade -y
sudo apt install -y wget gpg python3-venv python3-pip curl
# 2. Install Mainline Kernel 6.18+ (Required for RDNA 4 Memory Mapping)
if [[ $(uname -r) != "6.18"* ]]; then
echo "📦 Installing Kernel 6.18.7 via Mainline..."
sudo add-apt-repository ppa:cappelikan/ppa -y
sudo apt update && sudo apt install mainline -y
# Note: Automated install of unsigned kernels is risky.
# Manual reboot and Secure Boot disable is recommended.
echo "⚠️ ACTION REQUIRED: Reboot into Kernel 6.18.7 and DISABLE Secure Boot before continuing."
fi
# 3. Add ROCm 7.2 Repositories
echo "📦 Adding ROCm 7.2.0 Repositories..."
sudo mkdir -p --mode=0755 /etc/apt/keyrings
wget https://repo.radeon.com -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com noble main" | sudo tee /etc/apt/sources.list.d/rocm.list
sudo apt update
# 4. Install ROCm Stack
echo "📦 Installing ROCm 7.2.0 SDK and Drivers..."
sudo apt install -y rocm-hip-sdk amd-smi
# 5. Set Hardware Permissions
sudo usermod -a -G render,video $USER
# 6. Create Virtual Environment and Install Nightly PyTorch
echo "🐍 Setting up Python Virtual Environment (ai_env)..."
python3 -m venv ~/ai_env
source ~/ai_env/bin/activate
# Force-install the 2026 RDNA 4 Optimized Nightly build as of today rocm7.1 will install 7.2 it might be different in the future.
pip install --pre --upgrade --force-reinstall torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/nightly/rocm7.1
# Install helper libraries
pip install transformers accelerate datasets pandas scikit-learn
# 7. Inject "Gold Standard" Environment Variables into Activation Script
echo "📝 Configuring RDNA 4 Optimization Variables..."
cat <<EOF >> ~/ai_env/bin/activate
# --- 2026 AMD AI OPTIMIZATIONS ---
# Force RDNA 4 Architecture Support
export HSA_OVERRIDE_GFX_VERSION=12.0.0
# Fix Memory Pre-allocation (OOM) Bug for RX 9060 XT
export PYTORCH_ALLOC_CONF="max_split_size_mb:32,garbage_collection_threshold:0.6"
# Align PyTorch with System ROCm 7.2 Libraries
export LD_LIBRARY_PATH=/opt/rocm-7.2.0/lib:/opt/rocm-7.2.0/lib64:\$LD_LIBRARY_PATH
# Enable Experimental RDNA 4 Attention Features
export TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL=1
# Wake up GPU from Deep Sleep for AI Workloads
sudo amd-smi set --perf-level high --gpu 0 > /dev/null 2>&1
# ---------------------------------
EOF
echo "✅ Setup Complete!"
echo "👉 Run 'source ~/ai_env/bin/activate' to begin."