Skip to content

Commit

Permalink
[BREAKING FOR RPMFUSION USERS] NVIDIA Drivers (#2862)
Browse files Browse the repository at this point in the history
* add nvidia-kmod

* add settings, xsettings, mock label

* oops

* add nvidia setting assets

* add libva-nvidia-driver

* add: nvidia-kmod-common w/ properietary defaults

* download the x86 version of the driver package when running common

* add nvidia-driver package

* I don't think we actually need i386

* add a readme, fix build error and clean up script

* add back the accursed tarball script, we can port the thing later

* add nvidia-modprobe

* update metadata, add nvidia-persistenced

* add update scripts to nvidia drivers

* add update scripts for every cuda package

* make the component fetch a separate function for memoization

* cusparse

* cusparselt is not from cuda toolkit

* add nvidia subrepo label for multirepo

* set version for nvidia tarball

* nvidia-driver: download tarballs on build time

* clean up inline prep script

* NVProf is dropped in Jetpack 5, so there's no ARM version of it.
  • Loading branch information
korewaChino authored Jan 12, 2025
1 parent a80f8ea commit c72c975
Show file tree
Hide file tree
Showing 79 changed files with 3,812 additions and 0 deletions.
3 changes: 3 additions & 0 deletions anda/lib/nvidia/compat-nvidia-repo/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_driver_version());
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-cccl/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_cccl"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-cudart/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_cudart"));
5 changes: 5 additions & 0 deletions anda/lib/nvidia/cuda-cudnn/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "andax/nvidia.rhai" as nvidia;
let series = "9.6.0"
let url = `https://developer.download.nvidia.com/compute/cudnn/redist/redistrib_${series}.json`;
let json = get(url).json();
rpm.version(json["cudnn"]["version"]);
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-cuobjdump/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_cuobjdump"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-cupti/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_cupti"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-cuxxfilt/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_cuxxfilt"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-gcc/anda.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ project pkg {
rpm {
spec = "cuda-gcc.spec"
}
labels {
updbranch = 1
}
}
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-gcc/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/bump_extras.rhai" as bump;

rpm.version(bump::bodhi("gcc13", labels.branch.as_bodhi_ver()));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-gdb/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_gdb"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-nvdisasm/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_nvdisasm"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-nvml/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_nvml_dev"));
2 changes: 2 additions & 0 deletions anda/lib/nvidia/cuda-nvprof/anda.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ project pkg {
rpm {
spec = "cuda-nvprof.spec"
}

arches = ["x86_64"]
}
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-nvprof/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_nvprof"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-nvprune/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_nvprune"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-nvrtc/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_nvrtc"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-nvtx/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_nvtx"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-profiler/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_profiler_api"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda-sanitizer/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_sanitizer_api"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/cuda/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("cuda_documentation"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libcublas/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libcublas"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libcudla/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libcudla"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libcufft/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libcufft"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libcurand/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libcurand"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libcusparse/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libcusparse"));
5 changes: 5 additions & 0 deletions anda/lib/nvidia/libcusparselt/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let series = "0.6.3"
let url = `https://developer.download.nvidia.com/compute/cusparselt/redist/redistrib_${series}.json`;
let json = get(url).json();

rpm.version(json["libcusparse_lt"]["version"]);
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libnvfatbin/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libnvfatbin"));
3 changes: 3 additions & 0 deletions anda/lib/nvidia/libnvjpeg/update.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "andax/nvidia.rhai" as nvidia;

rpm.version(nvidia::nvidia_component_version("libnvjpeg"));
43 changes: 43 additions & 0 deletions anda/system/nvidia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# The Terra NVIDIA Driver tree

This directory contains the Terra distribution of NVIDIA drivers.

These driver packages are based on negativo17's NVIDIA driver packages for Fedora, with very slight modifications for hardware compatibility, and conforming to the Terra packaging guidelines.

Unlike negativo17 and Nobara, we do not manually generate a tarball of the NVIDIA drivers, but directly generate them
on-the-fly from the NVIDIA installer. This ensures that the packages can be easily maintained and updated, as long as the
self-extracting NVIDIA installer still has the same command-line options.

One major difference for Terra's distro is that we install the closed-source kernel modules by default, instead of the newer open-source kernel modules. This is because the open-source modules only support GPUs that have a GSP (GPU System Processor), which only includes Turing (RTX 20 series) and newer GPUs. As we would like to still support older GPUs, we install the closed-source modules by default.

## How Terra unpacks the self-extracting archive

Instead of pre-generating the tarball, we run the NVIDIA installer with the `-x` flag to extract the contents directly to the build directory. We then make use of an RPM macro to set the new build directory as that tree.

```rpmspec
Source0: http://download.nvidia.com/XFree86/Linux-%{_arch}/%{version}/NVIDIA-Linux-%{_arch}-%{version}.run
... skip to the %prep section ...
%prep
sh %{SOURCE0} -x --target nvidia-driver-%{version}
%setup -T -D -n nvidia-driver-%{version}
%build
... Build the package as usual ...
```

This is simpler than manually generating the tarball, but comes with a slight cost of having to download the NVIDIA installer every time we build any package that relies on that archive.

## Support

If you have any issues with the NVIDIA drivers, please file an issue on the [Terra Monorepo](https://github.com/terrapkg/packages/issues). We will try to help you as best as we can.

## License

The NVIDIA drivers are licensed under the NVIDIA Software License. Please refer to the [NVIDIA Software License](https://www.nvidia.com/content/DriverDownload-March2009/licence.php?lang=us) for more information.

We do not modify the actual NVIDIA drivers in any way, only providing a re-packaged version compatible with Ultramarine and Fedora.
9 changes: 9 additions & 0 deletions anda/system/nvidia/libva-nvidia-driver/anda.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project "pkg" {
rpm {
spec = "libva-nvidia-driver.spec"
}
arches = ["x86_64", "aarch64", "i386"]
labels = {
subrepo = "nvidia"
}
}
94 changes: 94 additions & 0 deletions anda/system/nvidia/libva-nvidia-driver/libva-nvidia-driver.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
%global commit0 259b7b7b7c6891805fbfb8f799d12ea03bd260f7
%global date 20241108
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})

%global upstream_name nvidia-vaapi-driver

Name: libva-nvidia-driver
Epoch: 1
Version: 0.0.13%{!?tag:^%{date}git%{shortcommit0}}
Release: 1%{?dist}
Summary: VA-API user mode driver for Nvidia GPUs
License: MIT
URL: https://github.com/elFarto/%{upstream_name}

%if "%{?shortcommit0}"
Source0: %{url}/archive/%{commit0}/%{upstream_name}-%{commit0}.tar.gz#/%{upstream_name}-%{shortcommit0}.tar.gz
%else
Source0: %{url}/archive/v%{version}/%{upstream_name}-%{version}.tar.gz
%endif

BuildRequires: gcc
BuildRequires: meson >= 0.58.0
BuildRequires: pkgconfig(egl)
BuildRequires: pkgconfig(ffnvcodec) >= 11.1.5.1
%if 0%{?fedora} || 0%{?rhel} >= 9
BuildRequires: pkgconfig(gstreamer-codecparsers-1.0)
%endif
BuildRequires: pkgconfig(libdrm) >= 2.4.60
BuildRequires: pkgconfig(libva) >= 1.8.0

Conflicts: libva-vdpau-driver%{?_isa}
Obsoletes: %{upstream_name} < 0.0.10-3
Provides: %{upstream_name} = %{version}-%{release}
# Alternative name that better describes the API involved
Provides: nvdec-vaapi-driver = %{version}-%{release}

Requires: mesa-filesystem

%description
This is a VA-API implementation that uses NVDEC as a backend. This
implementation is specifically designed to be used by Firefox for accelerated
decode of web content, and may not operate correctly in other applications.

%prep
%if "%{?shortcommit0}"
%autosetup -p1 -n %{upstream_name}-%{commit0}
%else
%autosetup -p1 -n %{upstream_name}-%{version}
%endif

%build
%meson
%meson_build

%install
%meson_install

%check
%meson_test

%files
%license COPYING
%doc README.md
%{_libdir}/dri/nvidia_drv_video.so

%changelog
* Sun Nov 10 2024 Simone Caronni <[email protected]> - 1:0.0.13^20241108git259b7b7-1
- Update to latest snapshot.
- Drop no longer needed patch.

* Fri Oct 04 2024 Simone Caronni <[email protected]> - 1:0.0.12^20240909git68efa33-2
- Update to latest snapshot.
- Add patch for 560/Wayland.

* Mon May 06 2024 Simone Caronni <[email protected]> - 1:0.0.12-1
- Update to 0.0.12.
- Trim changelog.
- Clean up SPEC file, allow it to build for EL8.

* Wed Nov 08 2023 Simone Caronni <[email protected]> - 0.0.11-1
- Update to 0.0.11.
- Rename to libva-nvidia-driver, as in main Fedora repository.

* Wed Jun 28 2023 Simone Caronni <[email protected]> - 0.0.10-1
- Update to 0.0.10.

* Mon Mar 20 2023 Simone Caronni <[email protected]> - 0.0.9-1.20230319gitc0a7f54
- Update to latest snapshot.

* Mon Feb 06 2023 Simone Caronni <[email protected]> - 0.0.8-2.20230205git17c62b8
- Add latest fixes.

* Sat Feb 04 2023 Simone Caronni <[email protected]> - 0.0.8-1.20230131git2bb71a5
- Rebase to latest snapshot.
4 changes: 4 additions & 0 deletions anda/system/nvidia/nvidia-driver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nvidia*/
NVIDIA*/
*.tar.*
*.run
8 changes: 8 additions & 0 deletions anda/system/nvidia/nvidia-driver/10-nvidia.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
Option "SLI" "Auto"
Option "BaseMosaic" "on"
EndSection
4 changes: 4 additions & 0 deletions anda/system/nvidia/nvidia-driver/70-nvidia-driver-cuda.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Enable persistence state. From:
# file:///usr/share/doc/nvidia-driver/html/nvidia-persistenced.html

enable nvidia-persistenced.service
11 changes: 11 additions & 0 deletions anda/system/nvidia/nvidia-driver/70-nvidia-driver.preset
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Enable complete power management. From:
# file:///usr/share/doc/nvidia-driver/html/powermanagement.html

enable nvidia-hibernate.service
enable nvidia-resume.service
enable nvidia-suspend.service

# Enable Dynamic Boost. From:
# file:///usr/share/doc/nvidia-driver/html/dynamicboost.html

enable nvidia-powerd.service
7 changes: 7 additions & 0 deletions anda/system/nvidia/nvidia-driver/alternate-install-present
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The NVIDIA proprietary driver is already installed in this system. It was
installed through a 3d party repository.

Please refer to the following page for additional information and to install
optional driver components:

https://negativo17.org/nvidia-driver/
12 changes: 12 additions & 0 deletions anda/system/nvidia/nvidia-driver/anda.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
project "pkg" {
rpm {
spec = "nvidia-driver.spec"
# We run the negativo17 generator script here because I genuinely tried fixing the spec file with our fancy patch and it didn't work
# TODO: Port it inside the specfile scripts
# pre_script = "nvidia-generate-tarballs.sh"
}
arches = ["x86_64", "aarch64", "i386"]
labels = {
subrepo = "nvidia"
}
}
47 changes: 47 additions & 0 deletions anda/system/nvidia/nvidia-driver/com.nvidia.driver.metainfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version='1.0' encoding='utf-8'?>
<component type="driver">
<id>com.nvidia.driver</id>
<suggests>
<id>nvidia-settings.desktop</id>
</suggests>
<name>NVIDIA Graphics Driver</name>
<icon type="local">/usr/share/pixmaps/com.nvidia.driver.png</icon>
<summary>NVIDIA Accelerated Graphics Driver</summary>
<developer id="com.nvidia">
<name>NVIDIA Corporation</name>
</developer>
<description>
<p>The NVIDIA Accelerated Linux Graphics Driver brings accelerated 2D functionality and high-performance OpenGL support to Linux with the use of NVIDIA graphics processing units.</p>
<p>These drivers provide optimized hardware acceleration for OpenGL and X applications and support nearly all recent NVIDIA GPU products. The NVIDIA graphics driver uses a Unified Driver Architecture: the single graphics driver supports all modern NVIDIA GPUs.</p>
</description>
<keywords>
<keyword>CUDA</keyword>
<keyword>GeForce</keyword>
<keyword>NVIDIA</keyword>
<keyword>OpenGL</keyword>
<keyword>Quadro</keyword>
<keyword>Tesla</keyword>
<keyword>Video</keyword>
<keyword>Vulkan</keyword>
<keyword>av1</keyword>
<keyword>avc</keyword>
<keyword>driver</keyword>
<keyword>h264</keyword>
<keyword>h265</keyword>
<keyword>hevc</keyword>
<keyword>jpeg</keyword>
<keyword>mpeg2</keyword>
<keyword>vaapi</keyword>
<keyword>vc-1</keyword>
<keyword>vp8</keyword>
<keyword>vp9</keyword>
</keywords>
<metadata_license>CC0-1.0</metadata_license>
<project_license>LicenseRef-proprietary:NVIDIA</project_license>
<url type="homepage">https://www.nvidia.com/</url>
<update_contact>https://github.com/terrapkg/packages/issues</update_contact>
<vcs-browser>https://github.com/terrapkg/packages</vcs-browser>
<custom>
<value key="GnomeSoftware::requires-akmods-key">True</value>
</custom>
</component>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c72c975

Please sign in to comment.