From 1d8d8def666d1e8b2f404ba1e97c93d6db899282 Mon Sep 17 00:00:00 2001 From: thelamer Date: Wed, 22 May 2024 12:30:59 -0400 Subject: [PATCH 1/2] add logic for injecting env vars on nvidia detection on non working Alpine branch along with docs --- Dockerfile | 5 +++- Dockerfile.aarch64 | 5 +++- readme-vars.yml | 33 +++++++++++++++++++++ root/defaults/startwm.sh | 8 +++++ root/etc/s6-overlay/s6-rc.d/svc-kasmvnc/run | 2 +- 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4e9d15c..6d5a4c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ RUN \ FROM ghcr.io/linuxserver/baseimage-alpine:3.19 as buildstage -ARG KASMVNC_RELEASE="d49d07b88113d28eb183ca7c0ca59990fae1153c" +ARG KASMVNC_RELEASE="511e2ae542e95f5447a0a145bb54ced968e6cfec" COPY --from=wwwstage /build-out /www @@ -287,6 +287,8 @@ RUN \ mesa-va-gallium \ mesa-vulkan-ati \ mesa-vulkan-intel \ + mesa-vulkan-layers \ + mesa-vulkan-swrast \ nginx \ nodejs \ openbox \ @@ -308,6 +310,7 @@ RUN \ setxkbmap \ sudo \ tar \ + vulkan-tools \ xauth \ xf86-video-amdgpu \ xf86-video-ati \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 04cea85..348c200 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -34,7 +34,7 @@ RUN \ FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.19 as buildstage -ARG KASMVNC_RELEASE="d49d07b88113d28eb183ca7c0ca59990fae1153c" +ARG KASMVNC_RELEASE="511e2ae542e95f5447a0a145bb54ced968e6cfec" COPY --from=wwwstage /build-out /www @@ -82,7 +82,9 @@ RUN \ mesa-vulkan-ati \ mesa-vulkan-broadcom \ mesa-vulkan-freedreno \ + mesa-vulkan-layers \ mesa-vulkan-panfrost \ + mesa-vulkan-swrast \ meson \ nettle-dev \ openssl-dev \ @@ -314,6 +316,7 @@ RUN \ setxkbmap \ sudo \ tar \ + vulkan-tools \ xauth \ xf86-video-amdgpu \ xf86-video-ati \ diff --git a/readme-vars.yml b/readme-vars.yml index a66d99d..513b664 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -189,6 +189,39 @@ full_custom_readme: | ### Display Compositing (desktop effects) When using this image in tandem with a supported video card, compositing will function albeit with a performance hit when syncing the frames with pixmaps for the applications using it. This can greatly increase app compatibility if the application in question requires compositing, but requires a real GPU to be mounted into the container. By default we disable compositing at a DE level for performance reasons on our downstream images, but it can be enabled by the user and programs using compositing will still function even if the DE has it disabled in its settings. When building desktop images be sure you understand that with it enabled by default only users that have a compatible GPU mounted in will be able to use your image. + + ## Nvidia GPU Support + + **Nvidia is not compatible with Alpine based images** + + Nvidia support is available by leveraging Zink for OpenGL support. This can be enabled with the following run flags: + + | Variable | Description | + | :----: | --- | + | --gpus all | This can be filtered down but for most setups this will pass the one Nvidia GPU on the system | + | --runtime nvidia | Specify the Nvidia runtime which mounts drivers and tools in from the host | + + The compose syntax is slightly different for this as you will need to set nvidia as the default runtime: + + ``` + sudo nvidia-ctk runtime configure --runtime=docker --set-as-default + sudo service docker restart + ``` + + And to assign the GPU in compose: + + ``` + services: + myimage: + image: myname/myimage:mytag + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [compute,video,graphics,utility] + ``` ## Lossless diff --git a/root/defaults/startwm.sh b/root/defaults/startwm.sh index d1f6c50..09bb011 100755 --- a/root/defaults/startwm.sh +++ b/root/defaults/startwm.sh @@ -1,2 +1,10 @@ #!/usr/bin/env bash + +# Enable Nvidia GPU support if detected +if vulkaninfo >/dev/null 2>&1 && which nvidia-smi; then + printf "1" > /run/s6/container_environment/LIBGL_KOPPER_DRI2 + printf "zink" > /run/s6/container_environment/MESA_LOADER_DRIVER_OVERRIDE + printf "zink" > /run/s6/container_environment/GALLIUM_DRIVER +fi + /usr/bin/openbox-session diff --git a/root/etc/s6-overlay/s6-rc.d/svc-kasmvnc/run b/root/etc/s6-overlay/s6-rc.d/svc-kasmvnc/run index aebd469..6eca289 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-kasmvnc/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-kasmvnc/run @@ -1,7 +1,7 @@ #!/usr/bin/with-contenv bash # Pass gpu flags if mounted -if ls /dev/dri/renderD* 1> /dev/null 2>&1 && [ -z ${DISABLE_DRI+x} ]; then +if ls /dev/dri/renderD* 1> /dev/null 2>&1 && [ -z ${DISABLE_DRI+x} ] && ! which nvidia-smi; then HW3D="-hw3d" fi if [ -z ${DRINODE+x} ]; then From 711f54240f7d27b18e9b41583711d11e8437e782 Mon Sep 17 00:00:00 2001 From: thelamer Date: Wed, 22 May 2024 13:14:24 -0400 Subject: [PATCH 2/2] fixes from bookworm testing --- root/defaults/startwm.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/root/defaults/startwm.sh b/root/defaults/startwm.sh index 09bb011..a5e37ce 100755 --- a/root/defaults/startwm.sh +++ b/root/defaults/startwm.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash # Enable Nvidia GPU support if detected -if vulkaninfo >/dev/null 2>&1 && which nvidia-smi; then - printf "1" > /run/s6/container_environment/LIBGL_KOPPER_DRI2 - printf "zink" > /run/s6/container_environment/MESA_LOADER_DRIVER_OVERRIDE - printf "zink" > /run/s6/container_environment/GALLIUM_DRIVER +if which nvidia-smi; then + export LIBGL_KOPPER_DRI2=1 + export MESA_LOADER_DRIVER_OVERRIDE=zink + export GALLIUM_DRIVER=zink fi /usr/bin/openbox-session