-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall_cuda_proxmox.sh
More file actions
141 lines (112 loc) · 4.87 KB
/
install_cuda_proxmox.sh
File metadata and controls
141 lines (112 loc) · 4.87 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# Script to install nvidia-cuda-toolkit on Proxmox (Debian) from offical Nvidia repository
# Run as root
# Written by cyclone
# v2024-01-17; add support for Debian 11 & 12
# v2024-03-04; sanity checks, remove old cuda-keyring
# v2024-06-27; clean up script, post to github
# v2024-12-10; script no longer works on Proxmox 8.x (Debian 12) due to incompatible dependencies
# v2025-03-08; recommend using https://github.com/cyclone-github/scripts/blob/main/install_cuda.py
# Check if root
if [ "$EUID" -ne 0 ]; then
echo "Must be run as root"
exit 1
else
echo "Checking if root: OK"
fi
# Check if running on a Debian-based distro
if grep -qi debian /etc/os-release; then
echo "Checking if Debian-based distro: OK"
else
echo "This script is intended to run on Debian-based distributions only."
echo "Please install CUDA with https://github.com/cyclone-github/scripts/blob/main/install_cuda.sh"
exit 1
fi
# Check if running on Proxmox
if dpkg -l | grep -qi pve-manager; then
echo "Checking if Proxmox: OK"
else
echo "This script is intended to run on Proxmox and will install Proxmox Kernel Headers."
read -p "Are you sure you want to continue? (y/n): " choice
case "$choice" in
y|Y ) echo "Continuing...";;
n|N ) echo "Exiting script."; exit 1;;
* ) echo "Invalid choice. Exiting script."; exit 1;;
esac
fi
# Get Proxmox version
VERSION=$(pveversion)
if [[ $VERSION == pve-manager/7.* ]]; then
echo "Proxmox version detected $VERSION: OK"
else
echo "Unsupported Proxmox $VERSION version, exiting..."
exit 1
fi
cat <<EOF
##################################################################
Script will install nvidia-cuda-toolkit on Proxmox 7.x (Debian 11)
--> Script no longer works on Proxmox 8.x (Debian 12) <--
--> due to incompatible dependencies <--
--> This will remove all existing *cuda and *nvidia packages <--
Press any key to continue, or ctrl+c to cancel...
##################################################################
EOF
read
# Blacklist nouveau driver
echo "Blacklisting nouveau driver..."
echo "blacklist nouveau" > /etc/modprobe.d/blacklist-nouveau.conf &> /dev/null && echo "Ok" || echo "Failed"
# Enable contrib and non-free repositories
echo "Enabling contrib and non-free repositories..."
apt install software-properties-common -y &> /dev/null && echo "Ok" || echo "Failed"
add-apt-repository contrib
add-apt-repository non-free
# Install GCC
echo "Installing GCC..."
apt install gcc -y &> /dev/null && echo "Ok" || echo "Failed"
# Install pve headers
echo "Installing pve-headers..."
apt update
apt install pve-headers-$(uname -r) -y &> /dev/null && echo "Ok" || echo "Failed"
# Install DKMS
echo "Installing DKMS..."
apt install dkms -y &> /dev/null && echo "Ok" || echo "Failed"
# Update initramfs
echo "Updating initramfs..."
update-initramfs -u &> /dev/null && echo "Ok" || echo "Failed"
# Remove old cuda-keyring downloads
echo "Removing old cuda-keyring downloads..."
rm /var/lib/apt/lists/*cuda* /var/lib/apt/lists/*nvidia* cuda-keyring_1.* &> /dev/null && echo "Ok"
# Remove existing cuda and nvidia
echo "Removing previously installed nvidia & cuda programs..."
[ -x /usr/bin/nvidia-uninstall ] && /usr/bin/nvidia-uninstall
apt autoremove --purge "cuda*" "nvidia*" "libxnvctrl*" "libnvidia-*" -y &> /dev/null && echo "Ok" || echo "Failed"
# User options for cuda-keyring installation
echo "Select the cuda-keyring version to install:"
echo "1. Install cuda-keyring v1.1.1 for Debian 12 (No longer works on Proxmox 8.x due to incompatible dependencies)"
echo "2. Install cuda-keyring v1.1.1 for Debian 11"
echo "3. Install cuda-keyring v1.0.1 for Debian 11"
read -p "Enter your choice (1, 2, or 3): " choice
case $choice in
1) CUDA_KEYRING_URL="https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb" ;;
2) CUDA_KEYRING_URL="https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.1-1_all.deb" ;;
3) CUDA_KEYRING_URL="https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb" ;;
*) echo "Invalid choice"; exit 1 ;;
esac
echo "Downloading cuda-keyring..."
wget $CUDA_KEYRING_URL &> /dev/null && echo "Ok" || echo "Failed"
echo "Installing cuda-keyring..."
dpkg -i $(basename $CUDA_KEYRING_URL) &> /dev/null && echo "Ok" || echo "Failed"
# Run apt-update and dist-upgrade
echo "Running apt-update..."
apt update &> /dev/null && echo "Ok" || echo "Failed"
echo "Running dist-upgrade..."
apt dist-upgrade -y &> /dev/null && echo "Ok" || echo "Failed"
# Remove old packages
echo "Removing old packages..."
apt autoremove --purge -y &> /dev/null && echo "Ok" || echo "Failed"
# Install cuda
echo "Installing nvidia-cuda-toolkit... (this may take a while)"
apt install cuda -y && echo "Ok" || echo "Failed"
# Reboot computer
echo "Please reboot computer..."
# script end