This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.fedora
107 lines (84 loc) · 3.76 KB
/
Dockerfile.fedora
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
ARG FEDORA_VERSION
# Nvidia driver installer for Fedora Atomic
FROM fedora:${FEDORA_VERSION} as kmod_builder
ARG KERNEL_VERSION
ARG NVIDIA_DRIVER_VERSION
ARG ARCH
LABEL maintainer="Cloud Infrastructure <[email protected]" \
name="nvidia-driver-installer" \
version="latest" \
atomic.type="system" \
architecture=${ARCH}
RUN dnf -y update
RUN dnf -y install curl git binutils cpp gcc koji bc make pkgconfig pciutils unzip \
elfutils-libelf-devel openssl-devel module-init-tools
RUN export KERNEL_PATH=$(echo ${KERNEL_VERSION} | cut -f1 -d "-")/$(echo ${KERNEL_VERSION} | cut -f2 -d "-" | sed -E "s/(.*).${ARCH}/\1/")/${ARCH} && \
curl -s -O https://kojipkgs.fedoraproject.org//packages/kernel/${KERNEL_PATH}/kernel-devel-${KERNEL_VERSION}.rpm && \
curl -s -O https://kojipkgs.fedoraproject.org//packages/kernel/${KERNEL_PATH}/kernel-core-${KERNEL_VERSION}.rpm && \
curl -s -O https://kojipkgs.fedoraproject.org//packages/kernel/${KERNEL_PATH}/kernel-modules-${KERNEL_VERSION}.rpm && \
dnf localinstall -y kernel-core-${KERNEL_VERSION}.rpm \
kernel-devel-${KERNEL_VERSION}.rpm \
kernel-modules-${KERNEL_VERSION}.rpm && \
dnf clean all
ENV NVIDIA_DRIVER_URL "http://download.nvidia.com/XFree86/Linux-${ARCH}/${NVIDIA_DRIVER_VERSION}/NVIDIA-Linux-${ARCH}-${NVIDIA_DRIVER_VERSION}.run"
ENV KERNEL_PATH /usr/src/kernels
ENV NVIDIA_PATH /opt/nvidia
ENV NVIDIA_BUILD_PATH ${NVIDIA_PATH}/build
ENV NVIDIA_DL_PATH ${NVIDIA_PATH}/download
# NVIDIA driver
WORKDIR ${NVIDIA_DL_PATH}
RUN curl ${NVIDIA_DRIVER_URL} -o nv_driver_installer.run && \
chmod +x nv_driver_installer.run
RUN ${NVIDIA_PATH}/download/nv_driver_installer.run \
-z \
--accept-license \
--no-questions \
--ui=none \
--no-precompiled-interface \
--kernel-source-path=/lib/modules/${KERNEL_VERSION}/build \
--kernel-name=${KERNEL_VERSION} \
--no-nvidia-modprobe \
--no-drm \
--x-prefix=/usr \
--no-install-compat32-libs \
--installer-prefix=${NVIDIA_BUILD_PATH} \
--utility-prefix=${NVIDIA_BUILD_PATH} \
--opengl-prefix=${NVIDIA_BUILD_PATH} && \
mv ${NVIDIA_BUILD_PATH}/lib ${NVIDIA_BUILD_PATH}/lib64
#--force-selinux
# NOTE: x-prefix is set to a different location,
# to simply skip those components and not include them in the installation
RUN mkdir -p ${NVIDIA_BUILD_PATH}/lib/modules/ && \
cp -rf /lib/modules/${KERNEL_VERSION} ${NVIDIA_BUILD_PATH}/lib/modules/${KERNEL_VERSION}
### DEPLOY ###
FROM fedora:${FEDORA_VERSION}
LABEL maintainer="Cloud Infrastructure <[email protected]" \
name="nvidia-driver-installer" \
version="latest" \
atomic.type="system" \
architecture="${ARCH}"
ARG KERNEL_VERSION=4.15.4-300.fc27.x86_64
ARG NVIDIA_DRIVER_VERSION=415.18
RUN dnf -y update && \
dnf -y install module-init-tools pciutils && \
dnf -y autoremove && \
dnf clean all
ENV NVIDIA_DRIVER_VERSION ${NVIDIA_DRIVER_VERSION}
ENV KERNEL_VERSION ${KERNEL_VERSION}
ENV NVIDIA_PATH /opt/nvidia
ENV NVIDIA_BIN_PATH ${NVIDIA_PATH}/bin
ENV NVIDIA_LIB_PATH ${NVIDIA_PATH}/lib
ENV NVIDIA_MODULES_PATH ${NVIDIA_LIB_PATH}/modules/${KERNEL_VERSION}/kernel/drivers/video
COPY --from=kmod_builder /opt/nvidia/build ${NVIDIA_PATH}
COPY scripts/nvidia-mkdevs.sh ${NVIDIA_BIN_PATH}/nvidia-mkdevs
RUN mkdir -p /lib/modules && \
cp -rf ${NVIDIA_PATH}/lib/modules/${KERNEL_VERSION} /lib/modules/${KERNEL_VERSION}
ENV PATH $PATH:${NVIDIA_BIN_PATH}
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NVIDIA_LIB_PATH}
CMD depmod -a && \
modprobe -r nouveau && \
modprobe nvidia && \
modprobe nvidia-uvm && \
nvidia-mkdevs && \
cp -rfn ${NVIDIA_PATH}/bin /opt/nvidia-host && \
cp -rfn ${NVIDIA_PATH}/lib64 /opt/nvidia-host