From ecba7a40a91d5559d4ad71c9383907010cc0ae12 Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Tue, 24 Jan 2017 20:03:42 +0100 Subject: [PATCH] make cool-retro-term work with nvidia --- cool-retro-term/docker-compose.yml | 22 ++++++++++++++++++++++ cool-retro-term/launch | 24 +++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/cool-retro-term/docker-compose.yml b/cool-retro-term/docker-compose.yml index fa2f9cf..26ffd54 100644 --- a/cool-retro-term/docker-compose.yml +++ b/cool-retro-term/docker-compose.yml @@ -5,7 +5,13 @@ services: image: andrey01/cool-retro-term network_mode: bridge devices: + - /dev/nvidia0 + - /dev/nvidiactl + # - /dev/nvidia-uvm + # uncomment this when running NVIDIA Driver >= 361 + # - /dev/nvidia-modeset - /dev/dri + # - /dev/snd # - /dev/video0 volumes: - /tmp/.X11-unix:/tmp/.X11-unix:ro @@ -13,6 +19,22 @@ services: - /etc/localtime:/etc/localtime:ro - $HOME:/home/$USER - /etc/machine-id:/etc/machine-id:ro + # Ubuntu's NVIDIA driver: + - /usr/lib/nvidia-361-prime:/h1_64:ro + - /usr/lib/nvidia-340:/h2_64:ro + - /usr/lib/nvidia-340-prime:/h3_64:ro + - /usr/lib/nvidia-304:/h4_64:ro + - /usr/lib32/nvidia-361:/h5_32:ro + - /usr/lib32/nvidia-340:/h6_32:ro + - /usr/lib32/nvidia-304:/h7_32:ro + # Ubuntu's generic libGL: + - /usr/lib/x86_64-linux-gnu:/h8_64:ro + - /usr/lib/i386-linux-gnu:/h9_32:ro + # openSUSE's NVIDIA driver: + - /usr/X11R6/lib:/h10_32:ro + - /usr/X11R6/lib64:/h11_64:ro + - /usr/lib:/h12_32:ro + - /usr/lib64:/h13_64:ro environment: - DISPLAY=unix$DISPLAY - PULSE_SERVER=unix:$XDG_RUNTIME_DIR/pulse/native diff --git a/cool-retro-term/launch b/cool-retro-term/launch index 8f3092e..9cd2321 100644 --- a/cool-retro-term/launch +++ b/cool-retro-term/launch @@ -8,7 +8,29 @@ usermod --home /home/$USER $OLDUSER usermod --login $USER $OLDUSER echo "$USER ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/$USER -sudo PULSE_SERVER=${PULSE_SERVER:?} su -s /bin/bash -c /opt/cool-retro-term/cool-retro-term $USER + +# +# Add a user to a detected "video" group +# so that it can access the nvidia devices +# +if [ -e /dev/nvidiactl ]; then + GID=$(stat -c '%g' /dev/nvidiactl) + groupadd -r -g $GID nvidia1 + if [ $? -eq 0 ]; then + usermod -aG nvidia1 $USER + else + GROUP=$(stat -c '%G' /dev/nvidiactl) + usermod -aG $GROUP $USER + fi +fi + +# +# Try to load host's libGL (generic or Nvidia 32/64-bit) drivers +# +LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(echo /h{1..20}_{32,64} | tr ' ' ':')" +export LD_LIBRARY_PATH + +sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH:?} PULSE_SERVER=${PULSE_SERVER:?} su -s /bin/bash -c /opt/cool-retro-term/cool-retro-term $USER # QT_X11_NO_MITSHM - stops Qt form using the MIT-SHM X11 extension # sudo QT_X11_NO_MITSHM=${QT_X11_NO_MITSHM:-1} PULSE_SERVER=${PULSE_SERVER:?} su -s /bin/bash -c /opt/cool-retro-term/cool-retro-term $USER