Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

feat: auto-generate CDI yaml for nvidia #7

Merged
merged 1 commit into from
Oct 6, 2023
Merged
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
7 changes: 6 additions & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ ARG COREOS_VERSION="${COREOS_VERSION:-stable}"
COPY build*.sh /tmp
COPY certs /tmp/certs
ADD ublue-os-ucore-nvidia.spec \
/tmp/ublue-os-ucore-nvidia/ublue-os-ucore-nvidia.spec
/tmp/ublue-os-ucore-nvidia/ublue-os-ucore-nvidia.spec
ADD files/usr/lib/systemd/system/ublue-nvctk-cdi.service \
/tmp/ublue-os-ucore-nvidia/rpmbuild/SOURCES/ublue-nvctk-cdi.service
ADD files/usr/lib/systemd/system-preset/70-ublue-nvctk-cdi.preset \
/tmp/ublue-os-ucore-nvidia/rpmbuild/SOURCES/70-ublue-nvctk-cdi.preset


RUN /tmp/build-prep.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable ublue-nvctk-cdi.service
11 changes: 11 additions & 0 deletions files/usr/lib/systemd/system/ublue-nvctk-cdi.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=ublue nvidia container toolkit CDI auto-generation
ConditionFileIsExecutable=/usr/bin/nvidia-ctk
After=local-fs.target

[Service]
Type=oneshot
ExecStart=/usr/bin/nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml

[Install]
WantedBy=multi-user.target
13 changes: 12 additions & 1 deletion ublue-os-ucore-nvidia.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: ublue-os-ucore-nvidia
Version: 0.2
Version: 0.3
Release: 1%{?dist}
Summary: Additional files for nvidia driver support on CoreOS

Expand All @@ -11,6 +11,8 @@ Supplements: mokutil policycoreutils

Source0: nvidia-container-toolkit.repo
Source1: nvidia-container.pp
Source2: ublue-nvctk-cdi.service
Source3: 70-ublue-nvctk-cdi.preset

%description
Adds various runtime files for nvidia support on Fedora CoreOS.
Expand All @@ -22,19 +24,28 @@ Adds various runtime files for nvidia support on Fedora CoreOS.
%build
install -Dm0644 %{SOURCE0} %{buildroot}%{_datadir}/ublue-os/%{_sysconfdir}/yum.repos.d/nvidia-container-toolkit.repo
install -Dm0644 %{SOURCE1} %{buildroot}%{_datadir}/ublue-os/%{_datadir}/selinux/packages/nvidia-container.pp
install -Dm0644 %{SOURCE2} %{buildroot}%{_datadir}/ublue-os/%{_unitdir}/ublue-nvctk-cdi.service
install -Dm0644 %{SOURCE3} %{buildroot}%{_presetdir}/70-ublue-nvctk-cdi.preset

sed -i 's@enabled=1@enabled=0@g' %{buildroot}%{_datadir}/ublue-os/%{_sysconfdir}/yum.repos.d/nvidia-container-toolkit.repo

install -Dm0644 %{buildroot}%{_datadir}/ublue-os/%{_sysconfdir}/yum.repos.d/nvidia-container-toolkit.repo %{buildroot}%{_sysconfdir}/yum.repos.d/nvidia-container-toolkit.repo
install -Dm0644 %{buildroot}%{_datadir}/ublue-os/%{_datadir}/selinux/packages/nvidia-container.pp %{buildroot}%{_datadir}/selinux/packages/nvidia-container.pp
install -Dm0644 %{buildroot}%{_datadir}/ublue-os/%{_unitdir}/ublue-nvctk-cdi.service %{buildroot}%{_unitdir}/ublue-nvctk-cdi.service

%files
%attr(0644,root,root) %{_datadir}/ublue-os/%{_sysconfdir}/yum.repos.d/nvidia-container-toolkit.repo
%attr(0644,root,root) %{_datadir}/ublue-os/%{_datadir}/selinux/packages/nvidia-container.pp
%attr(0644,root,root) %{_datadir}/ublue-os/%{_unitdir}/ublue-nvctk-cdi.service
%attr(0644,root,root) %{_sysconfdir}/yum.repos.d/nvidia-container-toolkit.repo
%attr(0644,root,root) %{_datadir}/selinux/packages/nvidia-container.pp
%attr(0644,root,root) %{_unitdir}/ublue-nvctk-cdi.service
%attr(0644,root,root) %{_presetdir}/70-ublue-nvctk-cdi.preset

%changelog
* Fri Oct 6 2023 Benjamin Sherman <[email protected]> - 0.3
- add ublue-nvctk-cdi service to auto-generate NVIDIA CDI GPU definitions

* Wed Oct 04 2023 Benjamin Sherman <[email protected]> - 0.2
- use newer nvidia-container-toolkit repo
- repo provides newer toolkit, no longer requires config.toml
Expand Down