jupyter / docker-stacks

Ready-to-run Docker images containing Jupyter applications
https://jupyter-docker-stacks.readthedocs.io
Other
7.92k stars 2.98k forks source link

Segmentation fault when rendering plots with Mayavi inside Jupyter #669

Closed kmdouglass closed 5 years ago

kmdouglass commented 6 years ago

Problem description

I am unable to get Mayavi working in the Jupyter Docker images. The container is set up to use my host X server as the window system. Furthermore, I can import the mayavi package inside a notebook. However, the notebook kernel crashes when actually rendering a plot.

I realize this problem covers a broad range of topics, from Docker to OpenGL, so I am not quite sure where the best place to ask would be. Any pointers would be appreciated.

Thanks for the help!

What docker image you are using?

jupyter/minimal-notebook:03b897d05f16

What complete docker command do you run to launch the container (omitting sensitive values)?

socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:/tmp/.X11-unix/X0 &
docker run -p 8890:8888 --rm \
           -e DISPLAY=xxx.xxx.xxx.xxx:0 \
           -v "$PWD/work":/home/jovyan/work \
           --name telo \
       kmdouglass/telo:latest

I use the socat command to expose the UNIX socket for my host display to TCP port 6000. The Docker container's DISPLAY environment variable is then set to my host's IP address and uses device number '0'.

What steps do you take once the container is running to reproduce the issue?

  1. Visit http://localhost:8890 and enter the token
  2. Start a Python 3 notebook in the work directory
  3. Place these lines in an empty cell and run it:
from mayavi import mlab
mlab.init_notebook()
mlab.test_plot3d()

What do you expect to happen?

I expect to see a 3D plot in the Jupyter notebook.

What actually happens?

The kernel dies due to a segmentation fault and the following error:

ERROR: In /work/standalone-x64-build/VTK-source/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 797
vtkXOpenGLRenderWindow (0x31b39f0): GL version 2.1 with the gpu_shader4 extension is not supported by your graphics driver but is required for the new OpenGL rendering backend. Please update your OpenGL driver
. If you are using Mesa please make sure you have version 10.6.5 or later and make sure your driver in Mesa supports OpenGL 3.2.                                                                                

[I 10:57:01.966 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
kernel 21c9f5d8-9ded-431a-9e7b-381463b39ed7 restarted

The third line, mlab.test_plot3d() raises the error. The first two are fine.

Dockerfile

FROM jupyter/minimal-notebook:03b897d05f16
MAINTAINER Kyle M. Douglass <kyle.m.douglass@gmail.com>

USER root

RUN apt update && apt -y install --no-install-recommends \
    mesa-common-dev \
    mesa-utils \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

USER jovyan

ENV LIBGL_ALWAYS_INDIRECT 1

COPY . .

RUN pip install -r requirements.txt \
    && pip install . \
    && jupyter nbextension install --py mayavi --user \
    && jupyter nbextension enable --py mayavi --user

OpenGL information

Host machine

douglass@xxxxxx:~$ glxinfo | grep version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.3 (Core Profile) Mesa 13.0.6
OpenGL core profile shading language version string: 4.30
OpenGL version string: 3.0 Mesa 13.0.6
OpenGL shading language version string: 1.30
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 13.0.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10

Docker container

server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL version string: 1.4 (3.0 Mesa 13.0.6)

Note that I actually have the Mesa 18.0.5 Ubuntu packages installed, so I am guessing that the OpenGL version string is reporting the Mesa version used by my host.

Pip requirements.txt

numpy==1.14.5
pandas==0.23.1
matplotlib==2.2.2
h5py==2.8.0
tables==3.4.4
scipy==1.1.0
PolymerCpp==0.1.3
seaborn==0.8.1
mayavi==4.6.1
PyQt5==5.11.2

Additional information

douglass@xxxxxx:~$ uname -a
Linux xxxxxx 3.16.0-6-amd64 #1 SMP Debian 3.16.56-1+deb8u1 (2018-05-08) x86_64 GNU/Linux
parente commented 6 years ago

I'm not familiar with forwarding X from within containers spawned from these images or using mayavi. I've marked this question as help wanted in case someone in the community here has solved this before.

parente commented 5 years ago

We're starting to experiment with a general Q&A section on https://discourse.jupyter.org/c/questions to see if cross-technology questions like this one catch more attention from a broader community audience. You might try re-posting your question over there to see if someone with more experience in Mayavi can help.

I'm going to close this issue since it has been idle for some time now. If you do post the question again on the Discourse site, feel free to leave a link in a comment here for those that happen upon this closed issue.

mtkilic commented 5 years ago

@kmdouglass did you ever solve this issue. I am seeing same issue on my end and I haven't I didn't find any work around.

davide-q commented 1 year ago

@mtkilic were you? I have the same issue too ;-(