EQX55 commited on
Commit
1a415aa
·
verified ·
1 Parent(s): c996f41

Upload cuda.sh

Browse files
Files changed (1) hide show
  1. cuda.sh +63 -0
cuda.sh ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "--------------------------------------------------------------------"
5
+ echo "IMPORTANT: This script will install CUDA 12.8 on Ubuntu 22.04."
6
+ echo "Ensure that you have a compatible NVIDIA GPU and that any conflicting CUDA installations are removed."
7
+ echo "--------------------------------------------------------------------"
8
+ read -p "Are you sure you want to continue? (y/N): " confirmation
9
+ if [[ ! "$confirmation" =~ ^[Yy]$ ]]; then
10
+ echo "Aborting."
11
+ exit 1
12
+ fi
13
+
14
+ echo ">>> [1/9] Updating package lists..."
15
+ apt update
16
+
17
+ echo ">>> [2/9] Installing required dependencies..."
18
+ apt install -y build-essential dkms wget
19
+
20
+ echo ">>> [3/9] Downloading CUDA repository pin file..."
21
+ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
22
+ mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
23
+
24
+ echo ">>> [4/9] Downloading CUDA 12.8 local installer package..."
25
+ wget https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda-repo-ubuntu2204-12-8-local_12.8.1-570.124.06-1_amd64.deb
26
+
27
+ echo ">>> [5/9] Installing the CUDA repository package..."
28
+ dpkg -i cuda-repo-ubuntu2204-12-8-local_12.8.1-570.124.06-1_amd64.deb
29
+
30
+ echo ">>> [6/9] Adding the repository GPG key..."
31
+ cp /var/cuda-repo-ubuntu2204-12-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
32
+
33
+ echo ">>> [7/9] Updating package lists after adding CUDA repository..."
34
+ apt update
35
+
36
+ echo ">>> [8/9] Installing CUDA 12.8 with force overwrite..."
37
+ apt -o Dpkg::Options::="--force-overwrite" install -y cuda
38
+
39
+ echo ">>> [9/9] Setting up environment variables for CUDA..."
40
+ cat << 'EOF' > /etc/profile.d/cuda.sh
41
+ export PATH=/usr/local/cuda-12.8/bin${PATH:+:${PATH}}
42
+ export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
43
+ EOF
44
+ chmod +x /etc/profile.d/cuda.sh
45
+
46
+ echo ">>> Cleaning up apt cache..."
47
+ apt clean
48
+
49
+ echo ">>> Verifying CUDA installation..."
50
+ if command -v nvcc >/dev/null 2>&1; then
51
+ echo "CUDA installed successfully. nvcc version:"
52
+ nvcc --version
53
+ else
54
+ echo "nvcc not found. Please check the installation."
55
+ fi
56
+
57
+ echo ""
58
+ echo "--------------------------------------------------------------------"
59
+ echo "Done! CUDA 12.8 should now be installed on your system."
60
+ echo "--------------------------------------------------------------------"
61
+
62
+ exit 0
63
+