- Archlinux : VirtualGL
- Using NVIDIA GPUs in X-application on a headless node via VNC
- Headless nVidia Mini How-To
- Cannot open virtual Console
- VirtualGL : 把 application 的 OpenGL 呼叫轉送到另一個xserver,並且把這個 xserver render 的結果拿來,交給真正負責application 顯示的 x server
- Xorg : 負責一個GPU加速功能的 X server
- TurboVNC : 負責顯示
然後啟動一個 X server
然後啟動 TurboVNC server,這個server 會把畫面畫出來,並且傳給 vncviewer
然後用 vglrun 來啟動 application.
以 CARLA 為例,要在 headless server 上 remote run.
先 create 一個 nvidia 的 Xserver:
$ nvidia-xconfig --query-gpu-info Number of GPUs: 1 GPU #0: Name : NVIDIA TITAN RTX UUID : GPU-XXXXXXXXXXXX PCI BusID : PCI:1:0:0 Number of Display Devices: 1 Display Device 0 (TV-6): No EDID information available.看一下 GPU 的 PCI Bus Id.
然後 create 一個 xorg.conf:
$ sudo nvidia-xconfig -a --allow-empty-initial-configuration --use-display-device=None --virtual=1920x1080 --busid=PCI:1:0:0 Using X configuration file: "/etc/X11/xorg.conf". Option "AllowEmptyInitialConfiguration" "True" added to Screen "Screen0". Backed up file '/etc/X11/xorg.conf' as '/etc/X11/xorg.conf.backup' New X configuration file written to '/etc/X11/xorg.conf'然後因為 nvidia driver 版本大於 440.xx,所以在 xorg.conf 的 Screen 的地方加上:
Option "HardDPMS" "false"
啟動一個 Xserver session,為了讓一班 user 也能啟動 X session,要修改 /etc/X11/Xwrapper.conf,加入下面:
allowed_users=anybody needs_root_rights=yes然後 user 要在 tty group 裡。
啟動一個 X session,使用 display number 7
X.Org X Server 1.21.1.11 X Protocol Version 11, Revision 0 Current Operating System: Linux i7-14700 6.8.0-35-generic #35-Ubuntu SMP PREEMPT_DYNAMIC Mon May 20 15:51:52 UTC 2024 x86_64 Kernel command line: BOOT_IMAGE=/boot/vmlinuz-6.8.0-35-generic root=UUID=e4ea2afe-cc4e-42ce-a53f-5032e417f9f7 ro xorg-server 2:21.1.12-1ubuntu1.1 (For technical support please see http://www.ubuntu.com/support) Current version of pixman: 0.42.2 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.7.log", Time: Fri Jan 17 05:52:20 2025 (==) Using config file: "/etc/X11/xorg.conf" (==) Using system config directory "/usr/share/X11/xorg.conf.d" The XKEYBOARD keymap compiler (xkbcomp) reports: > Warning: Could not resolve keysym XF86CameraAccessEnable > Warning: Could not resolve keysym XF86CameraAccessDisable > Warning: Could not resolve keysym XF86CameraAccessToggle > Warning: Could not resolve keysym XF86NextElement > Warning: Could not resolve keysym XF86PreviousElement > Warning: Could not resolve keysym XF86AutopilotEngageToggle > Warning: Could not resolve keysym XF86MarkWaypoint > Warning: Could not resolve keysym XF86Sos > Warning: Could not resolve keysym XF86NavChart > Warning: Could not resolve keysym XF86FishingChart > Warning: Could not resolve keysym XF86SingleRangeRadar > Warning: Could not resolve keysym XF86DualRangeRadar > Warning: Could not resolve keysym XF86RadarOverlay > Warning: Could not resolve keysym XF86TraditionalSonar > Warning: Could not resolve keysym XF86ClearvuSonar > Warning: Could not resolve keysym XF86SidevuSonar > Warning: Could not resolve keysym XF86NavInfo Errors from xkbcomp are not fatal to the X server
啟動 Turbovnc 的 vnc server,負責 application 的 display,用 8 作為 display number:
$ /opt/TurboVNC/bin/vncserver :8 Desktop 'TurboVNC: i7-14700:8 (charles-chang)' started on display i7-14700:8 Starting applications specified in /opt/TurboVNC/bin/xstartup.turbovnc Log file is /home/charles/.vnc/i7-14700:8.log如果是第一次啟動,會要求給一個 vncviewer 用的 password.
vnc server 啟動之後,其他pc 就可以透過 viewer 來顯示 vncserver 的內容。
vncserver 的 service port 是 5900+display numner,
也就是說,剛剛的設定,service port 是 5908
之後就可以用 vglrun 來執行 application,讓執行程式使用 virtualgl 提供的 opengl 服務,並且經由 DISPLAY 變數傳送render 的結果:
~$ DISPLAY=:8 vglrun -d :7 glxgears先指定DISPLAY環境變數是:8 (VNCSERVER),然後用 "-d :7" 指定 opengl rendering 交給 display :7 (nvidia X session) 負責。