I've written an EGL application hat renders a scene using OpenGL and then writes the rendered scene to an image file. The application is based on the sample code found in the blog post here: (https://devblogs.nvidia.com/parallelforall/egl-eye-opengl-visualization-without-x-server/). The application works just as expected when it is run directly on an AWS p2 instance (Ubuntu 16-04). The applications fails, however, when run within an nvidia-docker container (nvidia/cuda:latest) running on the same p2 host. The problem is the function eglQueryDevicesEXT fails to find any devices. (For what it's worth, calling eglGetDisplay(EGL_DEFAULT_DISPLAY) also fails to get a display). Should I expect that an EGL/OpenGL application can run within an nvidia-docker container? If so, are there any modifications that must be made the the sample code provided in the previously referenced blog post?
In case it helps, here is the nvidia-smi output from the container:
| NVIDIA-SMI 378.13 Driver Version: 378.13 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla K80 Off | 0000:00:1E.0 Off | 0 |
| N/A 34C P8 30W / 149W | 129MiB / 11439MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
Unfortunately, OpenGL is not supported for now (see #11). This is on the roadmap for 2.0 though.
Thank you for the reply. Is the roadmap and its timeline available online anywhere?
@tpkover I am using EGL in a nvidia-docker now (Just got "hello world" of EGL working)
Certain nvidia drivers have problems, such as 375.39. After fixing the host (via comment 11), you then have to go and fix the nvidia driver mount point to match it. On a ubuntu system this can be accessed in /var/lib/nvidia-docker/volumes/nvidia_driver/375.39/lib64 and /var/lib/nvidia-docker/volumes/nvidia_driver/375.39/lib and you can patch it manually. Until the 2.0 Milestone, this method will hopefully allow you to keep working unofficially ;)
hi, @andyneff ,i have same problem, on ubuntu16.04 with nvidia-384, after ln /usr/lib/nvidia-384/libEGL.so -> libEGL.so.384.90 and /usr/lib/nvidia-384/libEGL.so.1 -> libEGL.so.384.90 , eglGetDisplay() still return EGL_NO_DISPLAY, how to "go and fix the nvidia driver mount point to match it"
@zhali It's been a while since I've looked at it. Here are my notes from March (No guarantee they will be of any help)
You mention /usr/lib/nvidia-384/libEGL.so. That looks like a host path to me. I don't recall adding the symlink there helping the nvidia-docker container. I had to go into the docker side volume and patch it there.
With nvidia-docker v1, on Ubuntu, the nvidia-driver volumes can be accessed and patched on the host side by:
cd /var/lib/nvidia-docker/volumes/nvidia_driver/384.90/lib64
ln -s libEGL.so.384.90 libEGL.so.1
cd /var/lib/nvidia-docker/volumes/nvidia_driver/384.90/lib
ln -s libEGL.so.384.90 libEGL.so.1
Alternatively, you can patch it in the Dockerfile
RUN mkdir /driver_hack && \
ln -s /usr/local/nvidia/lib64/libEGL.so.384.90 /driver_hack/libEGL.so.1
And then add /driver_hack to the LD_LIBRARY_PATH environment variable. I've done this for libGL.so in the past, but never tested it on libEGL.so.1.
Sorry for the delayed response, and hope this helps some.
Hi @andyneff ,
i am running nvidia docker v2 on AWS instance
when running the program i am getting the following error:
"error while loading shared libraries: libEGL.so.1: cannot open shared object file: No such file or directory"
is EGL not supported in v2.0?
if not how can i do a work around so that my container can access my server EGL drive?
@DanYelovitch I'm not sure I'll be of much help, as I haven't tried using v2 for EGL yet, and probably won't for a while.
NVIDIA_DRIVER_CAPABILITIES set to?Upon running nvidia-docker run -e NVIDIA_DRIVER_CAPABILITIES=compute,graphics,utility,video -it --rm nvidia/cuda bash I don't see a libEGL.so1 right away either, but I do see libEGL_nvidia.so.387.26 which is an important start, but I've recently converted my host from Mint to Fedora, so a lot is different.
We'll soon release new Docker images with libglvnd, it will provide the libEGL.so.1 library for dispatch.
@tpkover Could you describe how you setup your Amazon machine in a bit more detail? I wanted to do exactly the same but got this problem: LINK. For me, it does not work at all. I started the: Deep Learning AMI (Ubuntu) Version 10.0 AMI with p2.xlarge and compiled following code:
#include <assert.h>
#include <EGL/egl.h>
#include <stdio.h>
#include <iostream>
static const EGLint configAttribs[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
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[])
{
// 1. Initialize EGL
EGLDisplay eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
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);
std::cout << "EGL Ctx: " << eglCtx << std::endl;
assert (eglDpy != NULL);
assert (eglCfg != NULL);
assert (eglSurf != NULL);
assert (eglCtx != NULL);
eglMakeCurrent(eglDpy, eglSurf, eglSurf, eglCtx);
// from now on use your OpenGL context
// 6. Terminate EGL when finished
eglTerminate(eglDpy);
return 0;
}
apt-get install libgles2-mesa-dev --> installs EGL
g++ -o test hello.cpp -lEGL
./test
output:
EGL eglDpy: 0x55b6b64878b0
minor, major: 4, 1
EGL numConfigs: 0
EGL eglCfg: 0
EGL surf: 0
EGL Ctx: 0
test: hello.cpp:60: int main(int, char**): Assertion `eglCfg != NULL' failed.
@henzler Did you get EGL running in the end? I am having similar issues.
@henzler Did you get EGL running in the end? I am having similar issues.
I stopped trying as I have found a python library that was well suited for my problem. Good luck!
Most helpful comment
We'll soon release new Docker images with libglvnd, it will provide the
libEGL.so.1library for dispatch.