diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.postinst b/src/cloud-api-adaptor/podvm-mkosi/mkosi.postinst index a9d98191bb..55040a2386 100755 --- a/src/cloud-api-adaptor/podvm-mkosi/mkosi.postinst +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.postinst @@ -11,7 +11,7 @@ mv "${BUILDROOT}/etc/issue.d" "${BUILDROOT}/usr/lib/issue.d" || true echo "IMAGE_ID=\"podvm\"" echo "IMAGE_VERSION=\"${IMAGE_VERSION-v0.0.0}\"" echo "VARIANT_ID=\"${VARIANT_ID}\"" -} >> "${BUILDROOT}/etc/os-release" +} >>"${BUILDROOT}/etc/os-release" # remove unused units of legacy image rm -f "${BUILDROOT}"/etc/systemd/system/{run-image,run-kata\x2dcontainers}.mount diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.presets/system/mkosi.conf.d/fedora-gpu.conf b/src/cloud-api-adaptor/podvm-mkosi/mkosi.presets/system/mkosi.conf.d/fedora-gpu.conf new file mode 100644 index 0000000000..fb7dc83701 --- /dev/null +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.presets/system/mkosi.conf.d/fedora-gpu.conf @@ -0,0 +1,9 @@ +[Match] +Distribution=fedora + +[Content] +Packages= + nvidia-container-toolkit +# 570.172.08 or newer is required due to: https://github.com/NVIDIA/open-gpu-kernel-modules/issues/893 + nvidia-driver-cuda-570.172.08 + kmod-nvidia-open-dkms-570.172.08 diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/etc/modeprobe.d/blacklist_nv_alt.conf b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/etc/modeprobe.d/blacklist_nv_alt.conf new file mode 100644 index 0000000000..46baa47535 --- /dev/null +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/etc/modeprobe.d/blacklist_nv_alt.conf @@ -0,0 +1,2 @@ +blacklist nouveau +blacklist nova_core diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/etc/yum.repos.d/cuda-fedora.repo b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/etc/yum.repos.d/cuda-fedora.repo new file mode 100644 index 0000000000..5f213bde35 --- /dev/null +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/etc/yum.repos.d/cuda-fedora.repo @@ -0,0 +1,6 @@ +[cuda-fedora41-x86_64] +name=cuda-fedora41-x86_64 +baseurl=https://developer.download.nvidia.com/compute/cuda/repos/fedora41/x86_64 +enabled=1 +gpgcheck=1 +gpgkey=https://developer.download.nvidia.com/compute/cuda/repos/fedora41/x86_64/D42D0685.pub diff --git a/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/30-coco.preset b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/30-coco.preset index 3724f13816..ef49da9862 100644 --- a/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/30-coco.preset +++ b/src/cloud-api-adaptor/podvm-mkosi/mkosi.skeleton/usr/lib/systemd/system-preset/30-coco.preset @@ -10,3 +10,5 @@ enable setup-nat-for-imds.service enable gen-issue.service enable image-env.service enable scratch-storage.service + +enable nvidia-cdi.service diff --git a/src/cloud-api-adaptor/podvm/files/etc/systemd/system/multi-user.target.wants/nvidia-cdi.service b/src/cloud-api-adaptor/podvm/files/etc/systemd/system/multi-user.target.wants/nvidia-cdi.service new file mode 120000 index 0000000000..8a38586961 --- /dev/null +++ b/src/cloud-api-adaptor/podvm/files/etc/systemd/system/multi-user.target.wants/nvidia-cdi.service @@ -0,0 +1 @@ +../nvidia-cdi.service \ No newline at end of file diff --git a/src/cloud-api-adaptor/podvm/files/etc/systemd/system/nvidia-cdi.service b/src/cloud-api-adaptor/podvm/files/etc/systemd/system/nvidia-cdi.service new file mode 100644 index 0000000000..2f511fa78d --- /dev/null +++ b/src/cloud-api-adaptor/podvm/files/etc/systemd/system/nvidia-cdi.service @@ -0,0 +1,11 @@ +[Unit] +Description=Generate NVIDIA CDI Configuration +Before=kata-agent.service + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/generate-nvidia-cdi.sh +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/src/cloud-api-adaptor/podvm/files/usr/local/bin/generate-nvidia-cdi.sh b/src/cloud-api-adaptor/podvm/files/usr/local/bin/generate-nvidia-cdi.sh new file mode 100755 index 0000000000..e474b7e62a --- /dev/null +++ b/src/cloud-api-adaptor/podvm/files/usr/local/bin/generate-nvidia-cdi.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#load drivers +nvidia-ctk -d system create-device-nodes --control-devices --load-kernel-modules + +nvidia-persistenced +# set confidential compute to ready state +nvidia-smi conf-compute -srs 1 +# Generate NVIDIA CDI configuration +nvidia-ctk cdi generate --output=/var/run/cdi/nvidia.yaml > /var/log/nvidia-cdi-gen.log 2>&1