I am maintaining 2 snaps that make use of Vulkan, adding vulkan support for AMD and Intel GPU’s is a straightforward addition to the snapcraft.yaml:
Adding the following layouts:
layout:
/usr/share/vulkan:
symlink: $SNAP/usr/share/vulkan
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libvulkan_intel.so:
symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libvulkan_intel.so
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libvulkan_radeon.so:
Adding to staged packages:
stage-packages:
- libvulkan1
- mesa-vulkan-drivers
- vulkan-utils
However for Nvidia I haven’t found very clear instructions on how to add this or what the correct approach is?
What I was previously doing for my snaps to get Vulkan working on Nvidia was to stage the entire nvidia driver (nvidia-driver-400
). This got Vulkan working but added around 150MB to the snap, also I’m not sure if there are downsides to this approach if a user is using a different driver version on their machine? I went with this approach after looking at the documentation here (Adding OpenGL/GPU support to a snap) mentioning to stage the GPU drivers. Using this approach I also noticed when selecting the Vulkan device in my snap it would show the GPU twice:
Recently I tried an alternative approach of setting VK_ICD_FILENAMES: "/var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json:$SNAP/usr/share/vulkan/icd.d/radeon.x86_64.json:$SNAP/usr/share/vulkan/icd.d/intel_icd.x86_64.json"
as an environment variable, which also got Vulkan to work. The issue with these filenames is that I dont know how to avoid having the x86_64 arch hardcoded for the Intel and Radeon ICD filenames. Using this approach I don’t see the duplicate Vulkan device when selecting the adapter:
If I use this approach I’m assuming this won’t work on an Ubuntu Core device due to the absence of Nvidia drivers?
For both approaches I also added the following layout, to follow the pattern with the AMD and Intel drivers:
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libGLX_nvidia.so.0:
symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libGLX_nvidia.so.0
But for the second approach I tried removing this to see if it would have any effect and it seems Vulkan works fine after the removal. I don’t know if removing this would have any unseen drawbacks.
So basically I’m just looking for clarification on what the correct approach for Nvidia Vulkan is, whether its one of the approaches mentioned above or something else. Also could the documentation for GPU support be expanded to mention setting up Vulkan?