Packaging templates for yum
and dnf
based Linux distros to build NVIDIA driver precompiled kernel modules.
For official packages see this table and developer blog post.
The main
branch contains this README and a sample build script. The .spec
files can be found in the appropriate rhel7, rhel8, and fedora branches.
- Overview
- Deliverables
- Prerequisites
- Demo
- Building with script
- Building Manually
- RPM Repository
- Installing packages
- Modularity Profiles
- Presentations
- Related
- Contributing
This repo contains the .spec
file used to build the following RPM packages:
note:
XXX
is the first.
delimited field in the driver version, ex:440
in440.33.01
-
RHEL8 or Fedora streams:
latest
andXXX
kmod-nvidia-${driver}-${kernel}-${driver}-${rel}.${dist}.${arch}.rpm > ex: kmod-nvidia-440.33.01-4.18.0-147.5.1-440.33.01-2.el8_1.x86_64.rpm > ex: kmod-nvidia-450.51.06-5.6.11-300-450.51.06-4.fc32.x86_64.rpm
note: requires
genmodules.py
to generatemodules.yaml
for modularity streams. -
RHEL7 flavor:
latest
kmod-nvidia-latest-${kernel}.r${driver}.${dist}.${arch}.rpm > ex: kmod-nvidia-latest-3.10.0-1062.18.1.r440.33.01.el7.x86_64.rpm
-
RHEL7 flavor:
branch-XXX
kmod-nvidia-branch-XXX-${kernel}.r${driver}.${dist}.${arch}.rpm > ex: kmod-nvidia-branch-440-3.10.0-1062.18.1.r440.33.01.el7.x86_64.rpm
These packages can be used in place of their equivalent DKMS packages:
-
RHEL8 or Fedora streams:
latest-dkms
andXXX-dkms
kmod-nvidia-latest-dkms-${driver}-${rel}.${dist}.${arch}.rpm > ex: kmod-nvidia-latest-dkms-440.33.01-1.el8.x86_64.rpm
-
RHEL7 flavor:
latest-dkms
kmod-nvidia-latest-dkms-${driver}-${rel}.${dist}.${arch}.rpm > ex: kmod-nvidia-latest-dkms-440.33.01-1.el7.x86_64.rpm
The latest
and latest-dkms
streams/flavors always update to the highest versioned driver, while the XXX
and XXX-dkms
streams/flavors lock driver updates to the specified driver branch.
note:
XXX-dkms
is not available for RHEL7
Supported branches: rhel7
, rhel8
& fedora
git clone -b ${branch} https://github.com/NVIDIA/yum-packaging-precompiled-kmod
> ex: git clone -b rhel8 https://github.com/NVIDIA/yum-packaging-precompiled-kmod
-
TRD location: http://us.download.nvidia.com/tesla/ (not browsable)
ex: http://us.download.nvidia.com/tesla/440.33.01/NVIDIA-Linux-x86_64-440.33.01.run
-
UDA location: http://download.nvidia.com/XFree86/Linux-x86_64/
ex: http://download.nvidia.com/XFree86/Linux-x86_64/440.64/NVIDIA-Linux-x86_64-440.64.run
-
CUDA runfiles:
cuda_${toolkit}_${driver}_linux.run
are not compatible.However a NVIDIA driver runfile can be extracted intact from a CUDA runfile:
sh cuda_${toolkit}_${driver}_linux.run --tar mxvf > ex: sh cuda_11.1.0_455.23.05_linux.run --tar mxvf ls builds/NVIDIA-Linux-${arch}-${driver}.run > ex: ls builds/NVIDIA-Linux-x86_64-455.23.05.run
note: these are only needed for building not installation
# Compilation
yum install gcc
# Kernel headers and source code
yum install kernel-headers-$(uname -r) kernel-devel-$(uname -r)
# Packaging
yum install rpm-build
# Enable EPEL to install DKMS
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm
yum install dkms
cd yum-packaging-precompiled-kmod
git checkout remotes/origin/main -- build.sh
note: distro:
fedora32
,rhel7
,rhel8
./build.sh path/to/*.run ${distro}
> ex: time ./build.sh ~/Downloads/NVIDIA-Linux-x86_64-440.33.01.run rhel8
mkdir nvidia-kmod-440.33.01-x86_64
sh NVIDIA-Linux-x86_64-440.33.01.run --extract-only --target .
mv kernel nvidia-kmod-440.33.01-x86_64/
tar -cJf nvidia-kmod-440.33.01-x86_64.tar.xz nvidia-kmod-440.33.01-x86_64
Generate X.509 public_key.der
and private_key.priv
files.
Example x509-configuration.ini. Replace $USER
and $EMAIL
values.
openssl req -x509 -new -nodes -utf8 -sha256 -days 36500 -batch \
-config x509-configuration.ini \
-outform DER -out public_key.der \
-keyout private_key.priv
note: Fedora users may need to
export IGNORE_CC_MISMATCH=1
mkdir BUILD BUILDROOT RPMS SRPMS SOURCES SPECS
cp public_key.der SOURCES/
cp private_key.priv SOURCES/
cp nvidia-kmod-440.33.01-x86-64.tar.xz SOURCES/
cp kmod-nvidia.spec SPECS/
rpmbuild \
--define "%_topdir $(pwd)" \
--define "debug_package %{nil}" \
--define "kernel $kernel" \
--define "kernel_release $release" \
--define "kernel_dist $dist" \
--define "driver $version" \
--define "epoch 3" \
--define "driver_branch $stream" \
-v -bb SPECS/kmod-nvidia.spec
# Kernel: 4.18.0-147.5.1
# Driver: 440.33.01
# Stream: latest
> ex: rpmbuild \
--define "%_topdir $(pwd)" \
--define "debug_package %{nil}" \
--define "kernel 4.18.0" \
--define "kernel_release 147.5.1" \
--define "kernel_dist .el8_1" \
--define "driver 440.33.01" \
--define "epoch 3" \
--define "driver_branch latest" \
-v -bb SPECS/kmod-nvidia.spec
If one does not already exist, generate a GPG key pair
gpg --generate-key
Set $gpgKey
to secret key ID.
gpgArgs="/usr/bin/gpg --force-v3-sigs --digest-algo=sha512 --no-verbose --no-armor --no-secmem-warning"
for package in RPMS/*/kmod-nvidia*.rpm; do
rpm \
--define "%_signature gpg" \
--define "%_gpg_name $gpgKey" \
--define "%__gpg /usr/bin/gpg" \
--define "%_gpg_digest_algo sha512" \
--define "%_binary_filedigest_algorithm 10" \
--define "%__gpg_sign_cmd %{__gpg} $gpgArgs -u %{_gpg_name} \
-sbo %{__signature_filename} %{__plaintext_filename}" \
--addsign "$package";
done
RHEL8 or Fedora
Copy relevant packages from the CUDA repository
* dnf-plugin-nvidia*.rpm
* cuda-drivers-${version}*.rpm
* nvidia-driver-${version}*.rpm
* nvidia-driver-cuda-${version}*.rpm
* nvidia-driver-cuda-libs-${version}*.rpm
* nvidia-driver-devel-${version}*.rpm
* nvidia-driver-libs-${version}*.rpm
* nvidia-driver-NvFBCOpenGL-${version}*.rpm
* nvidia-driver-NVML-${version}*.rpm
* nvidia-kmod-common-${version}*.rpm
* nvidia-libXNVCtrl-${version}*.rpm
* nvidia-libXNVCtrl-devel-${version}*.rpm
* nvidia-modprobe-${version}*.rpm
* nvidia-persistenced-${version}*.rpm
* nvidia-settings-${version}*.rpm
* nvidia-xconfig-${version}*.rpm
RHEL7
Copy relevant packages from the CUDA repository
* yum-plugin-nvidia*.rpm
* cuda-drivers-${version}*.rpm
* nvidia-driver-${flavor}-${version}*.rpm
* nvidia-driver-${flavor}-NVML-${version}*.rpm
* nvidia-driver-${flavor}-NvFBCOpenGL-${version}*.rpm
* nvidia-driver-${flavor}-cuda-${version}*.rpm
* nvidia-driver-${flavor}-cuda-libs-${version}*.rpm
* nvidia-driver-${flavor}-devel-${version}*.rpm
* nvidia-driver-${flavor}-libs-${version}*.rpm
* nvidia-libXNVCtrl-${version}*.rpm
* nvidia-libXNVCtrl-devel-${version}*.rpm
* nvidia-modprobe-${flavor}-${version}*.rpm
* nvidia-persistenced-${flavor}-${version}*.rpm
* nvidia-settings-${version}*.rpm
* nvidia-xconfig-${flavor}-${version}*.rpm
wget https://raw.githubusercontent.com/NVIDIA/cuda-repo-management/main/genmodules.py
mkdir my-first-repo
# Precompiled kmod package(s)
cp RPMS/*/kmod-nvidia*.rpm my-first-repo/
# Other NVIDIA driver packages
cp ~/Downloads/*.rpm my-first-repo/
RHEL8 or Fedora
createrepo_c -v --database my-first-repo/
python3 ./genmodules.py my-first-repo/ modules.yaml
modifyrepo_c modules.yaml my-first-repo/repodata
RHEL7
createrepo -v --database my-first-repo
Create custom.repo
file
[custom]
name=custom
baseurl=file:///path/to/my-first-repo
enabled=1
gpgcheck=0
Copy to system path for yum
/dnf
package manager
sudo cp custom.repo /etc/yum.repos.d/
Clean yum
/dnf
cache
yum clean all
note:
XXX
is the first.
delimited field in the driver version, ex:440
in440.33.01
- RHEL8 or Fedora streams:
latest
,XXX
,latest-dkms
,XXX-dkms
To switch streams, first uninstall and clear the current streamdnf module install nvidia-driver:${stream} > ex: dnf module install nvidia-driver:latest
dnf remove nvidia-driver dnf module reset nvidia-driver
- RHEL7 flavors:
latest
,branch-XXX
,latest-dkms
Then to installyum install nvidia-driver-${flavor} > ex: yum install nvidia-driver-latest
nvidia-settings
yum install cuda-drivers
-
RHEL8 or Fedora profiles:
default
,ks
,fm
,src
dnf module install nvidia-driver:${stream}/${profile} > ex: dnf module install nvidia-driver:450/fm
The default profile (
default
) installs all of the driver packages for specified stream using transitive closurednf module install nvidia-driver:${stream}/default
note: do not need to specify
default
profileThe kickstart profile (
ks
) is used for unattended Anaconda installs ofCentOS
,Fedora
, &RHEL
Linux OSes via a configuration file. This profile does not install the cuda-drivers metapackage, which otherwise would attempt to uninstall any existing NVIDIA driver runfiles via a%pretrans
hook%packages @^Minimal Install @nvidia-driver:${stream}/ks %end
note: any package warning is fatal to a kickstart installation
The NvSwitch profile (
fm
) installs all of the driver packages, as well as Fabric Manager and NCSQdnf module install nvidia-driver:${stream}/fm
note: this is intended for hardware containing NvSwitch such as DGX systems
The Source profile (
src
) installs only the contents of/usr/src/nvidia-${version}
which providesnv-p2p.h
and other header files used for compiling NVIDIA kernel modules such as GDRCopy and nvidia-fsnote: this profile is only compatible with precompiled streams (
latest
,XXX
); DKMS streams usekmod-nvidia-latest-dkms
dnf module install nvidia-driver:${stream}/src
note: this profile should be combined with another profile, i.e
default
,ks
, orfm
dnf module install nvidia-driver:${stream}/{default,src}
-
dnf-plugin-nvidia & yum-plugin-nvidia
-
nvidia-driver (and 6 more)
See CONTRIBUTING.md