Skip to content

Commit e87cab5

Browse files
FlorentPoinsautCopilot
andcommitted
Fix CUDA compilation for flatpak
Co-authored-by: Copilot <copilot@github.com>
1 parent d32cc0f commit e87cab5

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

flatpak/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ sed \
8686
-e "s| path: \.\.| path: ${REPO_CLEAN}|" \
8787
"${MANIFEST}" > "${PATCHED}"
8888

89+
# For non-nvidia variants, remove the CUDA runtime module (not needed).
90+
if [[ "${ACCELERATION}" != "nvidia" ]]; then
91+
sed -i '/# BEGIN_CUDA_RUNTIME_MODULE/,/# END_CUDA_RUNTIME_MODULE/d' "${PATCHED}"
92+
fi
93+
8994
# Copy all local files referenced by the manifest so flatpak-builder can find
9095
# them relative to the patched manifest location in WORK_DIR.
9196
cp "${SCRIPT_DIR}/com.obsproject.Studio.Plugin.LocalVocal.metainfo.xml" "${WORK_DIR}/"

flatpak/com.obsproject.Studio.Plugin.LocalVocal.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,38 @@ modules:
215215
cleanup:
216216
- /bin/patchelf
217217
- /bin
218+
219+
# CUDA runtime libraries (libcudart, libcublas) required by libggml-cuda.so.
220+
# org.freedesktop.Platform.GL.nvidia only ships the driver stub (libcuda.so.1);
221+
# the CUDA runtime toolkit libs must be bundled in the extension itself.
222+
# BEGIN_CUDA_RUNTIME_MODULE
223+
- name: cuda-runtime-libs
224+
buildsystem: simple
225+
build-commands:
226+
- |
227+
set -e
228+
DEST="${FLATPAK_DEST}/lib/obs-plugins/obs-localvocal"
229+
install -d "${DEST}"
230+
cp -L cudart/lib/libcudart.so.12 "${DEST}/libcudart.so.12"
231+
cp -L cublas/lib/libcublas.so.12 "${DEST}/libcublas.so.12"
232+
cp -L cublas/lib/libcublasLt.so.12 "${DEST}/libcublasLt.so.12"
233+
sources:
234+
- type: archive
235+
only-arches:
236+
- x86_64
237+
url: https://developer.download.nvidia.com/compute/cuda/redist/cuda_cudart/linux-x86_64/cuda_cudart-linux-x86_64-12.8.57-archive.tar.xz
238+
sha256: 5bd3ac35ea8e8ab880e595d5054ee373abf6d9e53dcb8cef0a5c75358dbc0ae2
239+
dest: cudart
240+
strip-components: 1
241+
- type: archive
242+
only-arches:
243+
- x86_64
244+
url: https://developer.download.nvidia.com/compute/cuda/redist/libcublas/linux-x86_64/libcublas-linux-x86_64-12.8.3.14-archive.tar.xz
245+
sha256: d634d545a670a43337741e1672b63ef9b989aaba15823f27ee4b4c7f43d790bb
246+
dest: cublas
247+
strip-components: 1
248+
# END_CUDA_RUNTIME_MODULE
249+
218250
# OBS LocalVocal - Main plugin
219251
- name: obs-localvocal
220252
buildsystem: cmake-ninja
@@ -275,6 +307,13 @@ modules:
275307
post-install:
276308
- install -Dm644 --target-directory=${FLATPAK_DEST}/share/metainfo
277309
${FLATPAK_BUILDER_BUILDDIR}/com.obsproject.Studio.Plugin.LocalVocal.metainfo.xml
310+
- |
311+
# Patch RPATH of libggml-cuda.so so it can find libcudart/libcublas
312+
# bundled alongside it in the same directory ($ORIGIN).
313+
SO="${FLATPAK_DEST}/lib/obs-plugins/obs-localvocal/libggml-cuda.so"
314+
if [ -f "${SO}" ]; then
315+
${FLATPAK_DEST}/bin/patchelf --set-rpath '$ORIGIN' "${SO}"
316+
fi
278317
279318
cleanup:
280319
- /uic-wrapper

0 commit comments

Comments
 (0)