-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.base-nvidia
More file actions
69 lines (58 loc) · 2.58 KB
/
Containerfile.base-nvidia
File metadata and controls
69 lines (58 loc) · 2.58 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
# Pureblue OS Base - NVIDIA Proprietary (Self-Built)
# Base image with self-built NVIDIA proprietary drivers from RPM Fusion
ARG FEDORA_VERSION
ARG REGISTRY
FROM ${REGISTRY}/base:${FEDORA_VERSION}
ARG FEDORA_VERSION
ARG REGISTRY
# Get kernel version
RUN KERNEL_VERSION=$(rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}') && \
echo "Building for kernel: ${KERNEL_VERSION}" && \
echo "${KERNEL_VERSION}" > /tmp/kernel-version
# Add RPM Fusion repositories
RUN dnf5 install -y \
https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${FEDORA_VERSION}.noarch.rpm \
https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${FEDORA_VERSION}.noarch.rpm
# Install NVIDIA userspace packages from RPM Fusion
RUN dnf5 install -y \
--enablerepo=rpmfusion-nonfree-updates \
nvidia-driver \
nvidia-driver-cuda \
nvidia-settings \
nvidia-kmod-common \
&& dnf5 clean all
# Install akmod-nvidia and build dependencies from RPM Fusion
RUN dnf5 install -y \
--enablerepo=rpmfusion-nonfree-updates \
akmod-nvidia \
kernel-devel-$(cat /tmp/kernel-version) \
gcc \
make \
elfutils-libelf-devel \
&& dnf5 clean all
# Build the kernel module using akmods
# No KERNEL_MODULE_TYPE set = builds proprietary drivers (default)
RUN KERNEL_VERSION=$(cat /tmp/kernel-version) && \
akmods --force --kernels "${KERNEL_VERSION}" --kmod "nvidia"
# Verify the modules were built and match the driver version
RUN KERNEL_VERSION=$(cat /tmp/kernel-version) && \
NVIDIA_KO=$(find /usr/lib/modules/"${KERNEL_VERSION}" -name "nvidia.ko*" -type f | head -1) && \
if [ -z "${NVIDIA_KO}" ]; then \
echo "ERROR: nvidia.ko not found in /usr/lib/modules/${KERNEL_VERSION}"; \
find /usr/lib/modules/"${KERNEL_VERSION}" -type f -name "*nvidia*" 2>/dev/null || true; \
exit 1; \
fi && \
echo "Found NVIDIA module at: ${NVIDIA_KO}" && \
KMOD_VERSION=$(modinfo -F version "${NVIDIA_KO}") && \
echo "Built kmod-nvidia version: ${KMOD_VERSION}" && \
DRIVER_VERSION=$(rpm -q --qf '%{VERSION}' xorg-x11-drv-nvidia) && \
echo "xorg-x11-drv-nvidia version: ${DRIVER_VERSION}" && \
if [ "${KMOD_VERSION}" != "${DRIVER_VERSION}" ]; then \
echo "ERROR: Version mismatch! kmod=${KMOD_VERSION}, driver=${DRIVER_VERSION}"; \
exit 1; \
fi
# Add nvidia-container-toolkit repo for container GPU support
RUN curl -Lo /etc/yum.repos.d/nvidia-container-toolkit.repo \
https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo || true
# Cleanup
RUN rm -f /tmp/kernel-version