blob: c23db6f3a690e46ea5805a99e81459937985ff13 (
plain)
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
|
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026 Open-IOV contributors
# setup_guest_driver.sh - Setup NVIDIA driver in QEMU guest
# Run this INSIDE the guest VM after installation
set -euo pipefail
echo "=========================================="
echo "Setting up NVIDIA driver in guest"
echo "=========================================="
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo "ERROR: This script must be run as root"
exit 1
fi
# Check kernel version
KERNEL_VER=$(uname -r)
echo "Kernel: $KERNEL_VER"
# Install dependencies
echo "Installing build dependencies..."
apt-get update
apt-get install -y \
build-essential \
dkms \
linux-headers-"$KERNEL_VER" \
linux-headers-generic \
pciutils \
clinfo
# Check for NVIDIA GPU in guest
echo "Checking for NVIDIA GPU in guest..."
lspci -d 10de: | grep -E "VGA|3D controller" || {
echo "WARNING: No NVIDIA GPU detected in guest"
echo "Make sure QEMU is started with -device vfio-pci,sysfsdev=..."
}
# Option 1: Install from Ubuntu repository (easiest)
echo ""
echo "Choose installation method:"
echo " 1) Ubuntu repository (nvidia-driver-550-open)"
echo " 2) NVIDIA runfile (latest)"
echo " 3) Build from source (open-gpu-kernel-modules)"
read -p "Select [1-3]: " choice
case $choice in
1)
echo "Installing from Ubuntu repository..."
apt-get install -y nvidia-driver-550-open
;;
2)
echo "Downloading NVIDIA runfile..."
RUNFILE="NVIDIA-Linux-x86_64-570.144.run"
wget -q "https://us.download.nvidia.com/XFree86/Linux-x86_64/570.144/$RUNFILE"
chmod +x "$RUNFILE"
./"$RUNFILE" --silent --dkms --no-opengl-files
;;
3)
echo "Building from open-gpu-kernel-modules source..."
git clone https://github.com/NVIDIA/open-gpu-kernel-modules.git /tmp/open-gpu-kernel-modules
cd /tmp/open-gpu-kernel-modules
git checkout 570.144
make -C kernel-open/modules SYSSRC=/usr/src/linux-headers-"$KERNEL_VER" -j$(nproc)
make -C kernel-open/modules SYSSRC=/usr/src/linux-headers-"$KERNEL_VER" modules_install
depmod -a
;;
*)
echo "Invalid choice"
exit 1
;;
esac
# Install firmware
echo "Installing GSP firmware..."
mkdir -p /lib/firmware/nvidia/tu102/gsp
# Firmware files should be copied from host or downloaded
# For TU104 (Turing), we need:
# - bootloader-535.113.01.bin
# - booter_load-535.113.01.bin
# - gsp-535.113.01.bin
echo "Copy firmware files to /lib/firmware/nvidia/tu102/gsp/"
echo " (bootloader, booter_load, gsp binaries)"
# Load driver
echo "Loading NVIDIA driver..."
modprobe nvidia
# Verify
echo ""
echo "=========================================="
echo "Verification"
echo "=========================================="
nvidia-smi
echo ""
dmesg -T | grep -i nvidia | tail -20
echo ""
echo "Setup complete! Recommended: reboot the guest"
|