Skip to content

Commit

Permalink
snapcraft/wrappers/nvidia-container-cli: support kernel-gpu-2404
Browse files Browse the repository at this point in the history
When mesa-2404 snap is used in conjunction with kernel-gpu-2404 interface:
snap connect mesa-2404:kernel-gpu-2404 pc-kernel

and pc-kernel snap nvidia component is installed we can use it to get
a required NVIDIA libraries instead of looking for them on the host
which enables a support for LXD on Ubuntu Core scenario.

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
  • Loading branch information
mihalicyn committed Oct 21, 2024
1 parent ed356bc commit 9f64ece
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions snapcraft/wrappers/nvidia-container-cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/sh

# Set the root path
exec nvidia-container-cli.real -r /var/lib/snapd/hostfs/ "$@"
#
# This is a bit hacky, as we rely on a library names but at the moment,
# we don't have any way to distinguish generic mesa-2404 snap from
# mesa-2404 snap with NVIDIA drivers connected to it. (At least, I don't know one.)
# Let's do this like that for now at least for PoC purpose.
#
if snapctl is-connected gpu-2404 &&
[ -f "${SNAP}/gpu-2404-2/usr/lib/x86_64-linux-gnu/libnvidia-ml.so" ] &&
[ -f "${SNAP}/gpu-2404-2/usr/lib/x86_64-linux-gnu/libcuda.so" ];
then
# We have NVIDIA drivers snap connected, let's use it
exec nvidia-container-cli.real "$@"
else
# Set the root path to use NVIDIA libraries from the host
exec nvidia-container-cli.real -r /var/lib/snapd/hostfs/ "$@"
fi

0 comments on commit 9f64ece

Please sign in to comment.