10

I'm trying to get opengl working for headless offscreen rendering on a Amazon p2 instance with Ubuntu Ubuntu Server 16.04.

After instance creation I've installed the appropriate nvidia drivers according to this amazon article, and they seem to be working as expected:

$ lsmod | grep nvidia
nvidia_drm             53248  0
nvidia_modeset        790528  1 nvidia_drm
nvidia              11911168  1 nvidia_modeset
drm_kms_helper        155648  3 cirrus,nouveau,nvidia_drm
drm                   364544  7 ttm,drm_kms_helper,cirrus,nouveau,nvidia_drm

$ nvidia-smi -q | head
==============NVSMI LOG==============

Timestamp                           : Thu Jan 19 11:22:38 2017
Driver Version                      : 375.20

Attached GPUs                       : 1
GPU 0000:00:1E.0
Product Name                    : Tesla K80
Product Brand                   : Tesla

I'm then trying the steps from this related question:

sudo apt-get install xserver-xorg libglu1-mesa-dev freeglut3-dev mesa-common-dev libxmu-dev libxi-dev
sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024
sudo /usr/bin/X :0 &

Which does start X but running glxinfo does not work:

$ DISPLAY=:0 glxinfo
name of display: :0
Xlib:  extension "GLX" missing on display ":0".
Xlib:  extension "GLX" missing on display ":0".
(... line repeats couple of times ...)
Error: couldn't find RGB GLX visual or fbconfig

Changing the BusID in Xorg.conf as mentioned in the related stackoverflow question did not help.

$ lspci|grep VGA
00:02.0 VGA compatible controller: Cirrus Logic GD 5446

/etc/X11/xorg.conf
Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "Tesla K80"
    BusID          "PCI:0:2:0"
EndSection

I've googled quite intensively and it's unclear to me how to proceed next... Any help would be appreciated

Community
  • 1
  • 1
Filidor Wiese
  • 664
  • 8
  • 16

2 Answers2

6

The official documentation about this is http://www.nvidia.com/content/PDF/remote-viz-tesla-gpus.pdf "REMOTE VISUALIZATION ON SERVER-CLASS TESLA GPUS". Read page 15. You have to add BusID to nvidia-xconfig.

First, run nvidia-xconfig --query-gpu-info. This is my p2 instance result.

Number of GPUs: 1

GPU #0:
  Name      : Tesla K80
  UUID      : GPU-f13e8e90-5d2f-f9fb-b7a8-39edf9500698
  PCI BusID : PCI:0:30:0

  Number of Display Devices: 0

Then you need to run this.

sudo nvidia-xconfig --busid=PCI:0:30:0 --use-display-device=none --virtual=1280x1024

You can run Xorg server by sudo Xorg :1 .

The DISPLAY=:1 glxinfo result.

name of display: :1
display: :1  screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.4
server glx extensions:
    GLX_ARB_context_flush_control, GLX_ARB_create_context,
...
Yu Kobayashi
  • 386
  • 3
  • 6
1

When using NVidia please consider the information obsolete that is given in the related question you linked.

For about a year now the NVidia drivers support true headless operation without an X server running. See this exhaustive article given on the Nvidia developer blog: https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • I see. However, I'm trying to run a [headless-gl](https://github.com/stackgl/headless-gl#how-can-headless-gl-be-used-on-a-headless-linux-machine) node application. They themselves recommend using xvfb for this, which doesn't seem to be connecting to the GPU. When I uninstall the nvidia drivers it does work but then it's probably using the CPU instead. – Filidor Wiese Jan 19 '17 at 12:45
  • @FilidorWiese: Indeed Xvfb will never be GPU accelerated, because Xvfb *always* operates on a CPU-side framebuffer and doesn't know how to talk to device drivers. In general when working with NVidia GPUs you want to *never* install anything related to Mesa. NVidia and Mesa in general do not play well with each other. Truth to be told I think it would be more worthwhile to invest time into adding headless EGL support to node/headless-gl rather trying to duct tape around the issue. – datenwolf Jan 19 '17 at 12:52
  • @datenwolf I actually experimented with EGL headless context. The issue with it is that ,once you are also using CUDA toolkit with GL interop in the app,it won't work. – Michael IV Apr 20 '18 at 13:47
  • @MichaelIV: For EGL contexts you have to use the EGL interop functions: https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__EGL.html#group__CUDART__EGL – datenwolf Apr 20 '18 at 23:18