From bf403fb8de96a07da3cf90caf73738f4ab0c3f1a Mon Sep 17 00:00:00 2001 From: Wanjohi <71614375+wanjohiryan@users.noreply.github.com> Date: Mon, 1 Apr 2024 00:42:26 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(server):=20Add=20nvidia=20gpu?= =?UTF-8?q?=20passthrough=20support=20(#5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description **What(what issue does this code solve/what feature does it add):** Currently on `docker run --gpus 1 netris:server` and run `nvidia-smi` you get an error. **How(how does it solve it):** We add the relevant NVIDIA_* env variables to allow for gpu passthrough. ## Required Checklist: - [ ] I have added any necessary documentation and comments in my code (where appropriate) - [ ] I have added tests to make sure my code runs in all contexts ## Further comments Co-authored-by: Wanjohi <71614375+wanjohiryan@usersnoreply.github.com> --- server.Dockerfile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/server.Dockerfile b/server.Dockerfile index c6faf6a6..0ded026a 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -1,7 +1,7 @@ #This contains all the necessary libs for the server to work. #NOTE: KEEP THIS IMAGE AS LEAN AS POSSIBLE. -FROM ubuntu:latest +FROM ubuntu:22.04 #FIXME: install Vulkan drivers (should be done in the .scripts/gpu) #FIXME: install https://git.dec05eba.com/gpu-screen-recorder (should be done in the .scripts/stream) @@ -15,6 +15,8 @@ RUN apt update && \ apt install -y \ software-properties-common \ curl \ + apt-transport-https \ + apt-utils \ wget \ git \ jq \ @@ -32,5 +34,22 @@ COPY .scripts/ /usr/bin/netris/ RUN ls -la /usr/bin/netris \ && chmod +x /usr/bin/netris/proton +# Expose NVIDIA libraries and paths +ENV PATH=/usr/local/nvidia/bin:${PATH} \ + LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64 \ + # Make all NVIDIA GPUs visible by default + NVIDIA_VISIBLE_DEVICES=all \ + # All NVIDIA driver capabilities should preferably be used, check `NVIDIA_DRIVER_CAPABILITIES` inside the container if things do not work + NVIDIA_DRIVER_CAPABILITIES=all \ + # Disable VSYNC for NVIDIA GPUs + __GL_SYNC_TO_VBLANK=0 + #Install proton -RUN /usr/bin/netris/proton -i \ No newline at end of file +# RUN /usr/bin/netris/proton -i + +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini +ENTRYPOINT ["/tini", "--"] + +CMD [ "/bin/bash" ] \ No newline at end of file