Hello,
I have a remote server without a display and nvidia-drivers installed (384) and also cuda installed (9.0). When executing the basic example given here: https://devblogs.nvidia.com/egl-eye-opengl-visualization-without-x-server no display/devices can be found. What are possible reasons for that issue? I have also loaded the kernel module properly (lsmod | grep nvidia) and I have no clue what else I have to do to make it work? What are the requirements for an eglGetDisplay to not return NULL? What are the requirements in general for EGL to work? I thought propietary nvidia drivers would be sufficient?
#include <assert.h>
#include <EGL/egl.h>
#include <stdio.h>
#include <iostream>
#define EGL_EGLEXT_PROTOTYPES
#include <EGL/egl.h>
#include <EGL/eglext.h>
static const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_DEPTH_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE
};
static const int pbufferWidth = 9;
static const int pbufferHeight = 9;
static const EGLint pbufferAttribs[] = {
EGL_WIDTH, pbufferWidth,
EGL_HEIGHT, pbufferHeight,
EGL_NONE,
};
int main(int argc, char *argv[])
{
static const int MAX_DEVICES = 4;
EGLDeviceEXT eglDevs[MAX_DEVICES];
EGLint numDevices;
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =(PFNEGLQUERYDEVICESEXTPROC)
eglGetProcAddress("eglQueryDevicesEXT");
eglQueryDevicesEXT(MAX_DEVICES, eglDevs, &numDevices);
printf("Detected %d devices\n", numDevices);
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
eglGetProcAddress("eglGetPlatformDisplayEXT");
EGLDisplay eglDpy = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, eglDevs[0], 0);
//EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
// 1. Initialize EGL
std::cout << "EGL eglDpy: " << eglDpy << std::endl;
EGLint major, minor;
eglInitialize(eglDpy, &major, &minor);
std::cout << "minor, major: " << minor << ", " << major << std::endl;
// 2. Select an appropriate configuration
EGLint numConfigs;
EGLConfig eglCfg;
eglChooseConfig(eglDpy, configAttribs, &eglCfg, 1, &numConfigs);
std::cout << "EGL numConfigs: " << numConfigs << std::endl;
std::cout << "EGL eglCfg: " << eglCfg << std::endl;
// 3. Create a surface
//EGLSurface eglSurf = eglCreatePbufferSurface(eglDpy, eglCfg, pbufferAttribs);
//std::cout << "EGL surf: " << eglSurf << std::endl;
// 4. Bind the API
eglBindAPI(EGL_OPENGL_API);
// 5. Create a context and make it current
EGLContext eglCtx = eglCreateContext(eglDpy, eglCfg, EGL_NO_CONTEXT,NULL);
assert (eglDpy != NULL);
assert (eglCfg != NULL);
//assert (eglSurf != NULL);
eglMakeCurrent(eglDpy, EGL_NO_SURFACE, EGL_NO_SURFACE, eglCtx);
std::cout << "EGL Ctx: " << eglCtx << std::endl;
assert (eglCtx != NULL);
// 6. Terminate EGL when finished
eglTerminate(eglDpy);
return 0;
}
Detected 0 devices
EGL eglDpy: 0
minor, major: -803435328, 0
EGL numConfigs: 32767
EGL eglCfg: 0x601de8
test: hello.cpp:85: int main(int, char**): Assertion `eglDpy != NULL' failed.
Aborted
More information:
ldconfig -p | grep EGL
libEGL_nvidia.so.0 (libc6,x86-64) => /usr/lib/nvidia-384/libEGL_nvidia.so.0
libEGL_nvidia.so.0 (libc6) => /usr/lib32/nvidia-384/libEGL_nvidia.so.0
libEGL.so.1 (libc6,x86-64) => /usr/lib/nvidia-384/libEGL.so.1
libEGL.so.1 (libc6) => /usr/lib32/nvidia-384/libEGL.so.1
libEGL.so (libc6,x86-64) => /usr/lib/nvidia-384/libEGL.so
libEGL.so (libc6) => /usr/lib32/nvidia-384/libEGL.so
nvidia-smi
Sun Jun 10 16:37:36 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.111 Driver Version: 384.111 |
lsmod | grep nvidia
nvidia_uvm 671744 4
nvidia_drm 49152 0
nvidia_modeset 860160 1 nvidia_drm
nvidia 13144064 603 nv_peer_mem,nvidia_modeset,nvidia_uvm
drm_kms_helper 155648 1 nvidia_drm
drm 364544 4 ttm,drm_kms_helper,nvidia_drm