@@ -17,28 +17,65 @@ echo "CUDA_VERSION: $CUDA_VERSION"
17
17
18
18
# Install system dependencies
19
19
echo " Installing system dependencies..."
20
- sudo apt-get update
21
20
22
- # Set up LLVM 17 APT source with modern GPG key handling
23
- echo " Setting up LLVM 17 APT source with modern GPG key handling... "
24
-
25
- # Download and install GPG key to /usr/share/keyrings
26
- curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key |
27
- gpg --dearmor | sudo tee /usr/share/keyrings/llvm-archive-keyring.gpg > /dev/null
28
-
29
- # Make sure key file is readable by _apt
30
- sudo chmod a+r /usr/share/keyrings/llvm-archive-keyring.gpg
21
+ # Check if we have cached APT lists (indicates cache hit)
22
+ HAS_APT_CACHE=false
23
+ if [ -f " /var/lib/apt/lists/lock " ] || [ " $( ls -A /var/lib/apt/lists/ 2> /dev/null | wc -l ) " -gt 5 ] ; then
24
+ echo " ✅ Detected cached APT package lists "
25
+ HAS_APT_CACHE=true
26
+ else
27
+ echo " 📦 No APT cache found "
28
+ HAS_APT_CACHE=false
29
+ fi
31
30
32
- # Write APT source list, explicitly binding keyring file
33
- echo " deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" |
34
- sudo tee /etc/apt/sources.list.d/llvm-toolchain-jammy-17.list
31
+ # Set up LLVM 17 APT source with modern GPG key handling
32
+ echo " Setting up LLVM 17 APT source..."
33
+ NEED_SOURCE_UPDATE=false
34
+
35
+ # Check if LLVM source is already configured
36
+ if [ ! -f " /etc/apt/sources.list.d/llvm-toolchain-jammy-17.list" ]; then
37
+ echo " 📝 Configuring LLVM APT source..."
38
+
39
+ # Download and install GPG key to /usr/share/keyrings
40
+ curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key |
41
+ gpg --dearmor | sudo tee /usr/share/keyrings/llvm-archive-keyring.gpg > /dev/null
42
+
43
+ # Make sure key file is readable by _apt
44
+ sudo chmod a+r /usr/share/keyrings/llvm-archive-keyring.gpg
45
+
46
+ # Write APT source list, explicitly binding keyring file
47
+ echo " deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" |
48
+ sudo tee /etc/apt/sources.list.d/llvm-toolchain-jammy-17.list
49
+
50
+ NEED_SOURCE_UPDATE=true
51
+ echo " ✅ LLVM APT source configured"
52
+ else
53
+ echo " ✅ LLVM APT source already configured"
54
+ fi
35
55
36
- # Update package lists
37
- sudo apt-get update
56
+ # Smart APT update strategy
57
+ APT_UPDATED=false
58
+ if [ " $HAS_APT_CACHE " = " true" ] && [ " $NEED_SOURCE_UPDATE " = " false" ]; then
59
+ echo " 🚀 Using cached package lists, skipping initial update"
60
+ APT_UPDATED=false
61
+ elif [ " $NEED_SOURCE_UPDATE " = " true" ]; then
62
+ echo " 🔄 Updating package lists (new source added)..."
63
+ sudo apt-get update
64
+ APT_UPDATED=true
65
+ else
66
+ echo " 🔄 Updating package lists (no cache available)..."
67
+ sudo apt-get update
68
+ APT_UPDATED=true
69
+ fi
38
70
39
71
# Install clang and clangd first
40
72
echo " Installing clang and clangd..."
41
- sudo apt-get install -y clang-17 clangd-17
73
+ if command -v clang-17 & > /dev/null && command -v clangd-17 & > /dev/null; then
74
+ echo " ✅ clang-17 and clangd-17 already installed"
75
+ else
76
+ echo " 📦 Installing clang-17 and clangd-17..."
77
+ sudo apt-get install -y clang-17 clangd-17
78
+ fi
42
79
43
80
# Set up clang alternatives
44
81
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-17 100
@@ -47,7 +84,42 @@ sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-17 100
47
84
48
85
# Install CUDA and development libraries
49
86
echo " Installing CUDA and development libraries..."
50
- sudo apt-get install -y cuda-toolkit-12.8 libstdc++6 libstdc++-12-dev libffi-dev libncurses-dev zlib1g-dev libxml2-dev git build-essential
87
+
88
+ # Check for specific CUDA 12.8 version
89
+ CUDA_VERSION_REQUIRED=" 12.8"
90
+ HAS_CORRECT_CUDA=false
91
+
92
+ if command -v nvcc & > /dev/null; then
93
+ # Get CUDA version from nvcc
94
+ INSTALLED_CUDA_VERSION=$( nvcc --version | grep " release" | sed -n ' s/.*release \([0-9]\+\.[0-9]\+\).*/\1/p' )
95
+ if [ " $INSTALLED_CUDA_VERSION " = " $CUDA_VERSION_REQUIRED " ]; then
96
+ echo " ✅ CUDA $CUDA_VERSION_REQUIRED already installed"
97
+ HAS_CORRECT_CUDA=true
98
+ else
99
+ echo " ⚠️ Found CUDA $INSTALLED_CUDA_VERSION , but need $CUDA_VERSION_REQUIRED "
100
+ HAS_CORRECT_CUDA=false
101
+ fi
102
+ else
103
+ echo " 📦 No CUDA toolkit found"
104
+ HAS_CORRECT_CUDA=false
105
+ fi
106
+
107
+ if [ " $HAS_CORRECT_CUDA " = " true" ]; then
108
+ echo " 🔧 Installing development libraries only..."
109
+ # Install other dev libraries but skip CUDA toolkit
110
+ sudo apt-get install -y libstdc++6 libstdc++-12-dev libffi-dev libncurses-dev zlib1g-dev libxml2-dev git build-essential
111
+ else
112
+ # Need to install CUDA - ensure package lists are updated
113
+ if [ " $APT_UPDATED " = " false" ]; then
114
+ echo " 🔄 Updating package lists before CUDA installation..."
115
+ sudo apt-get update
116
+ APT_UPDATED=true
117
+ fi
118
+
119
+ echo " 📦 Installing CUDA $CUDA_VERSION_REQUIRED and development libraries..."
120
+ # Install all packages including CUDA toolkit (this is the big download)
121
+ sudo apt-get install -y cuda-toolkit-12.8 libstdc++6 libstdc++-12-dev libffi-dev libncurses-dev zlib1g-dev libxml2-dev git build-essential
122
+ fi
51
123
52
124
# Verify clang installation
53
125
echo " Verifying clang installation..."
0 commit comments