Skip to content

Commit

Permalink
feat(nvidia): Attempt to support NVIDIA open
Browse files Browse the repository at this point in the history
  • Loading branch information
EyeCantCU committed Oct 22, 2023
1 parent 097bc2b commit f7f9236
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ jobs:
cfile_suffix: [common, nvidia]
major_version: [37, 38, 39]
nvidia_version: [0, 470, 535]
nvidia_variant: [none, proprietary, open]
exclude:
- cfile_suffix: common
nvidia_variant: proprietary
- cfile_suffix: common
nvidia_variant: open
- cfile_suffix: common
nvidia_version: 470
- cfile_suffix: common
nvidia_version: 535
- cfile_suffix: nvidia
nvidia_variant: none
- cfile_suffix: nvidia
nvidia_version: 0
- nvidia_variant: open
nvidia_version: 470
- kernel_flavor: asus
major_version: 37
- kernel_flavor: surface
Expand All @@ -50,7 +59,11 @@ jobs:
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
if [[ "${{ matrix.cfile_suffix }}" == "nvidia" ]]; then
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}-${{ matrix.nvidia_version }}"
if [[ "${{ matrix.nvidia_variant }}" == "proprietary" ]]; then
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}-${{ matrix.nvidia_version }}"
else
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}-${{ matrix.nvidia_variant }}"
fi
else
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.major_version }}"
fi
Expand Down Expand Up @@ -133,6 +146,7 @@ jobs:
KERNEL_FLAVOR=${{ matrix.kernel_flavor }}
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
NVIDIA_MAJOR_VERSION=${{ matrix.nvidia_version }}
NVIDIA_DRIVER_VARIANT=${{ matrix.nvidia_variant }}
labels: ${{ steps.meta.outputs.labels }}
oci: false

Expand Down
5 changes: 3 additions & 2 deletions Containerfile.nvidia
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#Build from base, simpley because it's the smallest image
ARG SOURCE_IMAGE="${SOURCE_IMAGE:-base}"
ARG BASE_IMAGE="quay.io/fedora-ostree-desktops/${SOURCE_IMAGE}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"

FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"
ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION:-535}"
ARG NVIDIA_DRIVER_VARIANT="${NVIDIA_DRIVER_VARIANT:-proprietary}"
ARG KERNEL_FLAVOR="{KERNEL_FLAVOR:-main}"

COPY build*.sh /tmp
Expand Down
15 changes: 12 additions & 3 deletions build-kmod-nvidia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@ rpm-ostree install \
akmod-${NVIDIA_PACKAGE_NAME}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE} \
xorg-x11-drv-${NVIDIA_PACKAGE_NAME}-{,cuda,devel,kmodsrc,power}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE}

if [[ "${NVIDIA_DRIVER_VARIANT}" != "proprietary" ]]; then
rpm-ostree install rpmfusion-nonfree-release-tainted
rpm-ostree override replace --experimental \
akmod-${NVIDIA_PACKAGE_NAME}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE} \
--install akmod-${NVIDIA_PACKAGE_NAME}-${NVIDIA_DRIVER_VARIANT}*:${NVIDIA_MAJOR_VERSION}.*.fc${RELEASE}
fi

# Either successfully build and install the kernel modules, or fail early with debug output
KERNEL_VERSION="$(rpm -q "${KERNEL_NAME}" --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')"
NVIDIA_AKMOD_VERSION="$(basename "$(rpm -q "akmod-${NVIDIA_PACKAGE_NAME}" --queryformat '%{VERSION}-%{RELEASE}')" ".fc${RELEASE%%.*}")"
NVIDIA_LIB_VERSION="$(basename "$(rpm -q "xorg-x11-drv-${NVIDIA_PACKAGE_NAME}" --queryformat '%{VERSION}-%{RELEASE}')" ".fc${RELEASE%%.*}")"
NVIDIA_FULL_VERSION="$(rpm -q "xorg-x11-drv-${NVIDIA_PACKAGE_NAME}" --queryformat '%{EPOCH}:%{VERSION}-%{RELEASE}.%{ARCH}')"


akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}"
if [[ "${NVIDIA_DRIVER_VARIANT}" =~ "proprietary" ]]; then
akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}"
else
akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}"-"${NVIDIA_DRIVER_VARIANT}"
fi

modinfo /usr/lib/modules/${KERNEL_VERSION}/extra/${NVIDIA_PACKAGE_NAME}/nvidia{,-drm,-modeset,-peermem,-uvm}.ko.xz > /dev/null || \
(cat /var/cache/akmods/${NVIDIA_PACKAGE_NAME}/${NVIDIA_AKMOD_VERSION}-for-${KERNEL_VERSION}.failed.log && exit 1)
Expand All @@ -43,4 +53,3 @@ NVIDIA_FULL_VERSION=${NVIDIA_FULL_VERSION}
NVIDIA_AKMOD_VERSION=${NVIDIA_AKMOD_VERSION}
NVIDIA_LIB_VERSION=${NVIDIA_LIB_VERSION}
EOF

0 comments on commit f7f9236

Please sign in to comment.