Configuring x11vnc for Checking the GPU in a Linux Server#

x11vnc is a virtual network computing (VNC) server that provides remote access to an existing X session with any VNC viewer. You can use x11vnc to confirm that the NVIDIA GPU in a Linux server to which no display devices are directly connected is working as expected. Examples of servers to which no display devices are directly connected include a VM that is configured with NVIDIA vGPU, a VM that is configured with a pass-through GPU, and a headless physical host in a bare-metal deployment.

Before you begin, ensure that the following prerequisites are met:

  • The NVIDIA vGPU software software graphics driver for Linux is installed on the server.

  • A secure shell (SSH) client is installed on your local system:

    • On Windows, you must use a third-party SSH client such as PuTTY.

    • On Linux, you can run the SSH client that is included with the OS from a shell or terminal window.

Configuring x11vnc involves following the sequence of instructions in these sections:

  1. Configuring the Xorg Server on the Linux Server

  2. Installing and Configuring x11vnc on the Linux Server

  3. Using a VNC Client to Connect to the Linux Server

After connecting to the server, you can use NVIDIA X Server Settings to confirm that the NVIDIA GPU is working as expected.

Configuring the Xorg Server on the Linux Server#

You must configure the Xorg server to specify which GPU or vGPU is to be used by the Xorg server if multiple GPUs are installed in your server and to allow the Xorg server to start even if no connected display devices can be detected.

  1. Log in to the Linux server.

  2. Determine the PCI bus identifier of the GPUs or vGPUs on the server.

    # nvidia-xconfig --query-gpu-info
    Number of GPUs: 1
    
    GPU #0:
      Name      : GRID T4-2Q
      UUID      : GPU-ea80de2d-1dd8-11b2-8305-c955f034e718
      PCI BusID : PCI:2:2:0
    
      Number of Display Devices: 0
    
  3. In a plain text editor, edit the /etc/X11/xorg.conf file to specify the GPU is to be used by the Xorg server and allow the Xorg server to start even if no connected display devices can be detected.

    1. In the Device section, add the PCI bus identifier of GPU to be used by the Xorg server.

      Section "Device"
          Identifier     "Device0"
          Driver         "nvidia"
          VendorName     "NVIDIA Corporation"
          BusID          "PCI:2:2:0"
      EndSection
      

      Note

      The three numbers in the PCI BusID obtained by nvidia-xconfig in the previous step are hexadecimal numbers. They must be converted to decimal numbers in the PCI bus identifier in the Device section. For example, if the PCI bus identifier obtained in the previous step is PCI:A:10:0, it must be specified as PCI:10:16:0 in the PCI bus identifier in the Device section.

    2. In the Screen section, ensure that the AllowEmptyInitialConfiguration option is set to True.

      Section "Screen"
          Identifier     "Screen0"
          Device         "Device0"
          Option         "AllowEmptyInitialConfiguration" "True"
      EndSection
      
  4. Restart the Xorg server in one of the following ways:

    • Restart the server.

    • Run the startx command.

    • If the Linux server is in run level 3, run the init 5 command to run the server in graphical mode.

  5. Confirm that the Xorg server is running.

    # ps -ef | grep X
    

    On Ubuntu, this command displays output similar to the following example.

    root     16500 16499  2 03:01 tty2     00:00:00 /usr/lib/xorg/Xorg -nolisten tcp :0 -auth /tmp/serverauth.s7CE4mMeIz
    root      1140  1126  0 18:46 tty1     00:00:00 /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/121/gdm/Xauthority -background none -noreset -keeptty -verbose 3
    root     17011 17108  0 18:50 pts/0    00:00:00 grep --color=auto X
    

    On Red Hat Enterprise Linux, this command displays output similar to the following example.

    root      5285  5181  0 16:29 pts/0    00:00:00 grep --color=auto X
    root      5880     1  0 Jun13 ?        00:00:00 /usr/bin/abrt-watch-log -F Backtrace /var/log/Xorg.0.log -- /usr/bin/abrt-dump-xorg -xD
    root      7039  6289  0 Jun13 tty1     00:00:03 /usr/bin/X :0 -background none -noreset -audit 4 -verbose -auth /run/gdm/auth-for-gdm-vr4MFC/database -seat seat0 vt1
    

Installing and Configuring x11vnc on the Linux Server#

Unlike other VNC servers, such as TigerVNC or Vino, x11vnc does not create an extra X session for remote access. Instead, x11vnc provides remote access to the existing X session on the Linux server.

  1. Install the required x11vnc package and any dependent packages.

    • For distributions based on Red Hat, use the yum package manager to install the x11vnc package.

      # yum install x11vnc
      
    • For distributions based on Debian, use the apt package manager to install the x11vnc package.

      # sudo apt install x11vnc
      
    • For SuSE Linux distributions, install x11vnc from the x11vnc openSUSE Software page.

  2. Get the display numbers of the servers for the Xorg server.

    # cat /proc/*/environ 2>/dev/null | tr '\0' '\n' | grep '^DISPLAY=:' | uniq
    DISPLAY=:0
    DISPLAY=:100
    
  3. Start the x11vnc server, specifying the display number to use.

    The following example starts the x11vnc server on display 0 on a Linux server that is running the Gnome desktop.

    # x11vnc -display :0 -auth /run/user/121/gdm/Xauthority -forever \
    -shared -ncache -bg
    

    Note

    If you are using a C-series vGPU, omit the -ncache option.

    The x11vnc server starts on display <hostname>:0, for example, my-linux-host:0.

    26/03/20200 04:23:13
    The VNC desktop is:      my-linux-host:0
    PORT=5900
    

Using a VNC Client to Connect to the Linux Server#

  1. On your client computer, install a VNC client such as TightVNC.

  2. Start the VNC client and connect to the Linux server.

    Screen capture showing the New TightVNC Connection dialog box.Screen capture showing the New TightVNC Connection dialog box.

    The X session on the server opens in the VNC client.

    Screen capture showing a Gnome desktop X session in the TightVNC Viewer window.Screen capture showing a Gnome desktop X session in the TightVNC Viewer window.

Troubleshooting: If your VNC client cannot connect to the server, change permissions on the Linux server as follows:

  1. Allow the VNC client to connect to the server by making one of the following changes:

    • Disable the firewall and the iptables service.

    • Open the VNC port in the firewall.

  2. Ensure that permissive mode is enabled for Security Enhanced Linux (SELinux).

After connecting to the server, you can use NVIDIA X Server Settings to confirm that the NVIDIA GPU is working as expected.

Screen capture showing NVIDIA X Server Settings running in a Gnome desktop X session in the TightVNC Viewer window.Screen capture showing NVIDIA X Server Settings running in a Gnome desktop X session in the TightVNC Viewer window.