Skip to content

Commit

Permalink
Add documentation for packaging kmod-nvidia-open-dkms and compiling o…
Browse files Browse the repository at this point in the history
…pen modules from source

Signed-off-by: Kevin Mittman <kmittman@nvidia.com>
  • Loading branch information
kmittman committed Jun 15, 2022
1 parent 83a44c1 commit e8fe773
Showing 1 changed file with 83 additions and 2 deletions.
85 changes: 83 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The `main` branch contains this README and a sample build script. The `.spec` an

## Deliverables

This repo contains the `.spec` file used to build the following **RPM** packages:
This repo contains the `.spec` file(s) used to build the following **RPM** packages:

> *note:* `XXX` is the first `.` delimited field in the driver version, ex: `460` in `460.32.03`
Expand All @@ -51,6 +51,15 @@ This repo contains the `.spec` file used to build the following **RPM** packages
> ex: kmod-nvidia-latest-dkms-460.32.03-1.el7.x86_64.rpm
```

* [Open GPU Kernel Modules](https://github.com/NVIDIA/open-gpu-kernel-modules) streams available in `515` and newer: `open-dkms` and `XXX-open`
```shell
kmod-nvidia-open-dkms-${version}-${rel}.${dist}.${arch}.rpm
> ex: kmod-nvidia-open-dkms-515.48.07-1.el9.x86_64.rpm
> ex: kmod-nvidia-open-dkms-515.43.04-1.fc35.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
Expand Down Expand Up @@ -92,6 +101,9 @@ git clone -b ${branch} https://github.com/NVIDIA/yum-packaging-dkms-nvidia
```shell
# Packaging
yum install rpm-build dkms

# Optional: compile open kernel modules from source
yum install g++
```


Expand All @@ -112,7 +124,7 @@ git checkout remotes/origin/main -- build.sh
```


## Building Manually
## Building Manually (legacy modules)

### Generate tarball from runfile

Expand All @@ -126,6 +138,7 @@ mv extract/kernel nvidia-kmod-${version}-${arch}/
tar -cJf nvidia-kmod-${version}-${arch}.tar.xz nvidia-kmod-${version}-${arch}
```


### Packaging (`dnf` distros)
> note: `fedora` & `rhel8`-based distros
Expand Down Expand Up @@ -169,6 +182,74 @@ rpmbuild \
> _note:_ to build `kmod-nvidia-branch-XXX` and `kmod-nvidia-latest` packages see [yum-packaging-precompiled-kmod](https://github.com/NVIDIA/yum-packaging-precompiled-kmod)


## Building Manually (open modules)

### Generate input

> _note:_ architecture is `x86_64`, or `aarch64` (sbsa)
#### Use runfile

This method uses pre-build nvidia.o and nvidia-drm.o modules included with the NVIDIA driver runfile

```shell
version="515.48.07"
sh NVIDIA-Linux-${arch}-${version}.run --extract-only --target extract
mkdir nvidia-open-kmod-${version}-${arch}
mv extract/kernel-open nvidia-open-kmod-${version}-${arch}/
tar -cJf nvidia-open-kmod-${version}-${arch}.tar.xz nvidia-open-kmod-${version}-${arch}
```

**or**

#### Use NVIDIA-kernel-module-source tarball

This method builds nvidia.o and nvidia-drm.o modules from [NVIDIA-kernel-module-source*.tar.xz](https://download.nvidia.com/XFree86/NVIDIA-kernel-module-source/)

Compile from source code
```shell
version="515.48.07"
tar -xf NVIDIA-kernel-module-source-${version}.tar.xz
cd NVIDIA-kernel-module-source-${version}
make -j6 modules
```

Copy .o modules to expected location (work-in-progress)
```shell
rm -f kernel-open/nvidia/nv-kernel.o_binary &&
cp -av src/nvidia/_out/Linux_${arch}/nv-kernel.o kernel-open/nvidia/nv-kernel.o_binary
rm -f kernel-open/nvidia-modeset/nv-modeset-kernel.o_binary &&
cp -av src/nvidia-modeset/_out/Linux_${arch}/nv-modeset-kernel.o kernel-open/nvidia-modeset/nv-modeset-kernel.o_binary
```

Create input tarball
```
cd ..
mkdir nvidia-open-kmod-${version}-${arch}
mv NVIDIA-kernel-module-source-${version}/kernel-open nvidia-open-kmod-${version}-${arch}/
tar -cJf nvidia-open-kmod-${version}-${arch}.tar.xz nvidia-open-kmod-${version}-${arch}
```

### Packaging (open modules)

```shell
mkdir BUILD BUILDROOT RPMS SRPMS SOURCES SPECS
cp dkms-nvidia.conf SOURCES/
cp nvidia-open-kmod-${version}-${arch}.tar.xz SOURCES/
cp NVIDIA-kernel-module-source-${version}.tar.xz SOURCES/
cp dkms-open-nvidia.spec SPECS/

rpmbuild \
--define "%_topdir $(pwd)" \
--define "debug_package %{nil}" \
--define "version $version" \
--define "epoch 3" \
--target "${arch}" \
-v -bb SPECS/dkms-open-nvidia.spec
```


## Related

### Precompiled kernel modules
Expand Down

0 comments on commit e8fe773

Please sign in to comment.