-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-nvidia-drivers.sh
More file actions
executable file
·36 lines (28 loc) · 1.01 KB
/
setup-nvidia-drivers.sh
File metadata and controls
executable file
·36 lines (28 loc) · 1.01 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
#!/bin/bash
set -e
echo "Installing NVIDIA Drivers on Debian 12..."
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root or with sudo"
exit 1
fi
# Update system
echo "Updating package lists..."
apt-get update
# Install kernel headers and build essentials
echo "Installing kernel headers and build tools..."
apt-get install -y linux-headers-$(uname -r) build-essential dkms
# Add non-free and contrib repositories if not already added
echo "Ensuring non-free and contrib repositories are enabled..."
if ! grep -q "non-free" /etc/apt/sources.list; then
sed -i 's/main$/main contrib non-free non-free-firmware/' /etc/apt/sources.list
apt-get update
fi
# Install NVIDIA drivers
echo "Installing NVIDIA drivers..."
apt-get install -y nvidia-driver firmware-misc-nonfree cuda-drivers
# Load nvidia module
echo "Loading NVIDIA kernel module..."
modprobe nvidia || true
echo "NVIDIA drivers installed successfully!"
echo "Note: A system reboot is required for the drivers to take effect."