Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions base/comps/kmod-nvidia-open/kmod-nvidia-open-modprobe.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Block conflicting kernel modules
blacklist nouveau
blacklist nvidiafb
blacklist rivafb

# Load NVIDIA modules with recommended options
options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
options nvidia-drm modeset=1
16 changes: 16 additions & 0 deletions base/comps/kmod-nvidia-open/kmod-nvidia-open.comp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[component-templates.kmod-nvidia-open]
description = "Out-of-tree driver built against multiple kernel versions and toolchains"

[component-templates.kmod-nvidia-open.default-component-config]
spec = { type = "local", path = "kmod-nvidia-open.spec" }

[[component-templates.kmod-nvidia-open.default-component-config.source-files]]
filename = "open-gpu-kernel-modules-595.58.03.tar.gz"
hash-type = "SHA256"
hash = "e0c4659ddf15e4f4e19cee05b49f88c9ba08ef3add0dfe08249798f58d0fe75e"
origin = { type = "download", uri = "https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/595.58.03.tar.gz" }

[[component-templates.kmod-nvidia-open.matrix]]
axis = "kernel"

[component-templates.kmod-nvidia-open.matrix.values.6-18]
134 changes: 134 additions & 0 deletions base/comps/kmod-nvidia-open/kmod-nvidia-open.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Azure Linux NVIDIA open GPU kernel modules
# Built from: https://github.com/NVIDIA/open-gpu-kernel-modules

# Kernel modules are built via kbuild outside the normal RPM build tree,
# so automatic debuginfo extraction fails with empty debugsourcefiles.list.
%global debug_package %{nil}

# Auto-detect the kernel version from the installed kernel-devel package.
# The kernel-devel package installs headers to /usr/src/kernels/<uname-r>.
# This is resolved at RPM build time (inside mock), after BuildRequires
# are installed — so the directory will exist.
#
# To override: rpmbuild --define 'kernel_uname_r 6.18.5-1.4.azl4.x86_64'
%{!?kernel_uname_r: %global kernel_uname_r %(ls -1 /usr/src/kernels/ 2>/dev/null | sort -V | tail -1)}

%global kmod_install_dir /lib/modules/%{kernel_uname_r}/extra/nvidia

Name: kmod-nvidia-open
Version: 595.58.03
Release: 3_%{kernel_uname_r}%{?dist}
Summary: NVIDIA open GPU kernel modules for CUDA workloads
License: MIT AND GPLv2
URL: https://github.com/NVIDIA/open-gpu-kernel-modules
Vendor: Microsoft Corporation
Distribution: Azure Linux
ExclusiveArch: x86_64 aarch64

Source0: https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/%{version}.tar.gz#/open-gpu-kernel-modules-%{version}.tar.gz
Source1: kmod-nvidia-open-modprobe.conf

BuildRequires: kernel-devel
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: make
BuildRequires: elfutils-libelf-devel
BuildRequires: binutils

Requires: kernel-uname-r = %{kernel_uname_r}
Requires(post): kmod
Requires(postun): kmod

Provides: nvidia-open-kmod = %{version}-%{release}
Provides: kmod-nvidia-open = %{version}-%{release}
Provides: kmod-nvidia-open-%{kernel_uname_r} = %{version}-%{release}

# Prevent conflicting NVIDIA driver packages from being installed
Conflicts: nvidia-driver-cuda
Conflicts: kmod-nvidia-open-dkms

%description
Open-source NVIDIA GPU kernel modules built from the official
NVIDIA/open-gpu-kernel-modules repository for kernel %{kernel_uname_r}.

These modules support CUDA workloads on NVIDIA GPUs with compute
capability 5.0 and later. The modules are built using the open-source
kernel module variant (nvidia-open).

Modules included:
- nvidia.ko (core driver)
- nvidia-modeset.ko (modesetting support)
- nvidia-drm.ko (DRM/KMS support)
- nvidia-uvm.ko (unified virtual memory)
- nvidia-peermem.ko (GPU peer memory for RDMA)

%prep
%autosetup -n open-gpu-kernel-modules-%{version}

%build
# Unset LDFLAGS — NVIDIA's kbuild invokes ld directly (not via gcc),
# so it doesn't understand the -Wl, prefix in RPM's default hardening flags.
unset LDFLAGS

# Build the open kernel modules
# KERNEL_UNAME must match the target kernel exactly
make %{?_smp_mflags} modules -j$(nproc) \
KERNEL_UNAME="%{kernel_uname_r}" \
SYSSRC="/usr/src/kernels/%{kernel_uname_r}" \
SYSOUT="/usr/src/kernels/%{kernel_uname_r}" \
IGNORE_CC_MISMATCH=1 \
IGNORE_XEN_PRESENCE=1 \
IGNORE_PREEMPT_RT_PRESENCE=1 \
NV_EXCLUDE_BUILD_MODULES="" \
INSTALL_MOD_DIR="extra/nvidia"

%install
install -d %{buildroot}%{kmod_install_dir}

# Install the built kernel modules
for mod in nvidia nvidia-modeset nvidia-drm nvidia-uvm nvidia-peermem; do
ko="kernel-open/${mod}.ko"
if [ -f "${ko}" ]; then
install -m 0644 "${ko}" %{buildroot}%{kmod_install_dir}/
fi
done

# Install modprobe configuration to blacklist conflicting modules
install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/modprobe.d/kmod-nvidia-open.conf

# Generate modules.dep metadata at build time (weak-modules support)
install -d %{buildroot}%{_sysconfdir}/depmod.d
cat > %{buildroot}%{_sysconfdir}/depmod.d/kmod-nvidia-open.conf << 'EOF'
# Ensure NVIDIA modules in extra/ override any in-tree modules
override nvidia %{kernel_uname_r} extra/nvidia
override nvidia-modeset %{kernel_uname_r} extra/nvidia
override nvidia-drm %{kernel_uname_r} extra/nvidia
override nvidia-uvm %{kernel_uname_r} extra/nvidia
override nvidia-peermem %{kernel_uname_r} extra/nvidia
EOF

%post
/usr/sbin/depmod -a %{kernel_uname_r} || :

%postun
/usr/sbin/depmod -a %{kernel_uname_r} || :

%files
%license COPYING
%{kmod_install_dir}/nvidia.ko
%{kmod_install_dir}/nvidia-modeset.ko
%{kmod_install_dir}/nvidia-drm.ko
%{kmod_install_dir}/nvidia-uvm.ko
%{kmod_install_dir}/nvidia-peermem.ko
%config(noreplace) %{_sysconfdir}/modprobe.d/kmod-nvidia-open.conf
%{_sysconfdir}/depmod.d/kmod-nvidia-open.conf

%changelog
* Thu Apr 10 2026 Elaheh Dehghani <edehghani@microsoft.com> - 595.58.03-2
- Auto-detect kernel version from installed kernel-devel package
- Remove hardcoded kernel_version macro dependency

* Thu Apr 09 2026 Elaheh Dehghani <edehghani@microsoft.com> - 595.58.03-1
- Initial Azure Linux 4.0 package
- Built from NVIDIA/open-gpu-kernel-modules upstream source
- Open-source kernel modules for CUDA workloads
15 changes: 15 additions & 0 deletions base/comps/nvidia-cuda-driver/nvidia-cuda-driver.comp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[components.nvidia-cuda-driver]
# Headless compute-only: no graphics/display components.
spec = { type = "local", path = "nvidia-cuda-driver.spec" }

[[components.nvidia-cuda-driver.source-files]]
filename = "NVIDIA-Linux-x86_64-595.58.03-no-compat32.run"
hash-type = "SHA256"
hash = "b66c59b9bebc191b9c21bad7476da1486dd390198223a548892110bca5fb91f9"
origin = { type = "download", uri = "https://us.download.nvidia.com/XFree86/Linux-x86_64/595.58.03/NVIDIA-Linux-x86_64-595.58.03-no-compat32.run" }

[[components.nvidia-cuda-driver.source-files]]
filename = "NVIDIA-Linux-aarch64-595.58.03.run"
hash-type = "SHA256"
hash = "873cc8298d537bc424081591f87e64d4507f1cad5480685a8ba725df011a3d3f"
origin = { type = "download", uri = "https://us.download.nvidia.com/XFree86/Linux-aarch64/595.58.03/NVIDIA-Linux-aarch64-595.58.03.run" }
Loading
Loading