neurodocker icon indicating copy to clipboard operation
neurodocker copied to clipboard

OpenGL support when using `--vnc`

Open pwighton opened this issue 5 years ago • 7 comments

I'm trying to get FreeSurfer's FreeView working in a docker container and accessable via a browser.

Is there a way to get openGL applications working with Neurodocker's --vnc flag?

What works

This works using the machinery in thewtex/opengl (not using --vnc). Neurodocker has been modified so the lib/qt directory isn't excluded when installing FreeSurfer.

Build

mesa-utils can be eventually removed, used to test with glxgears

neurodocker generate docker \
  --base thewtex/opengl:ubuntu1804 \
  --add-to-entrypoint "/usr/bin/supervisord -c /etc/supervisor/supervisord.conf" \
  --freesurfer version=7.1.0 \
  --pkg-manager apt \
  --install libglu1-mesa mesa-utils \
    | docker build -t pwighton/freeview:7.1.0-thewtex -

Run

Using the run.sh script from this repo

./run.sh \
  -p 6081 \
  -i pwighton/freeview:7.1.0-thewtex \
  -r --env="APP=freeview" \
  -r "-v /home/paul/lcn/data/fs-course-20200310:/subs"

Gives something that seems to work

What Doesn't work

Trying to get FreeView to work various other ways doesn't seem to work. The problem reduces to getting glxgears to work

Sharing the X socket

Based on this

Build:

neurodocker generate docker \
  --base continuumio/miniconda:4.7.12 \
  --pkg-manager apt \
  --install xserver-xorg-video-all libgl1-mesa-glx mesa-utils \
    | docker build -t glxgears-test -

Sharing the X socket and user details into the container:

xhost +
docker run -it --rm --privileged \
  -u $(id -u):$(id -g) \
  -e DISPLAY=$DISPLAY \
  -e HOME=/tmp/home \
  -v="/etc/group:/etc/group:ro" \
  -v="/etc/passwd:/etc/passwd:ro" \
  -v="/etc/shadow:/etc/shadow:ro" \
  -v="/etc/sudoers.d:/etc/sudoers.d:ro" \
  -v="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
  glxgears-test \
    glxgears

Gives

name of display: :0
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  54
  Current serial number in output stream:  53

Use thewtex/opengl with Neurodocker's --vnc

Trying to use thewtex/opengl:ubuntu1804 for the OpenGL drivers but the vnc from Neurodocker.

The container buils is similar to the working example above, except the line --add-to-entrypoint "/usr/bin/supervisord -c /etc/supervisor/supervisord.conf" is removed to disable thewtex/opengl's machinery and a --vnc flag is added

neurodocker generate docker \
  --base thewtex/opengl:ubuntu1804 \
  --pkg-manager apt \
  --install libglu1-mesa mesa-utils \
  --vnc passwd=paul123 start_at_runtime=true geometry=1920x1080 \
    | docker build -t pwighton/freeview:7.1.0-thewtex2 -

Running:

docker run --rm -it -p 5901:5901 \
    pwighton/freeview:7.1.0-thewtex2 \
      glxgears

Gives:

xauth:  file /root/.Xauthority does not exist

New 'X' desktop is b183b15febee:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/b183b15febee:1.log

Error: couldn't get an RGB, Double-buffered visual

A home built 'everything under the sun' container

With the --vnc flag

Build:

neurodocker generate docker \
  --base continuumio/miniconda:4.7.12 \
  --pkg-manager apt \
  --install \
      libglu1-mesa \
      libgl1-mesa-dri \
      libgl1-mesa-glx \
      mesa-utils \
      libmng-dev \
      qt5-default \
      libqt5x11extras5-dev \
  --vnc passwd=paul123 start_at_runtime=true geometry=1920x1080 \
  --run "pip install opencv-python-headless" \
    | docker build -t glxgears2 -

Running:

docker run --rm -it -p 5901:5901 \
    glxgears2 \
      glxgears

Gives:

xauth:  file /root/.Xauthority does not exist

New 'X' desktop is b2163bbf0b9f:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/b2163bbf0b9f:1.log

Error: couldn't get an RGB, Double-buffered visual

pwighton avatar May 15 '20 02:05 pwighton

thank you @pwighton - this is the most detailed issue ever reported on neurodocker. thanks for all of the details, it makes debugging much easier.

i have not been able to solve the issue yet, but from my digging online, it seems like virtualgl might be useful. also neurodocker installs the tightvnc server, and i'm not sure that tightvnc is compatible. the virtualgl folks suggest installing turbovnc in their documentation in using opengl over vnc.

see and https://cdn.rawgit.com/VirtualGL/virtualgl/2.6.3/doc/index.html#hd009 https://gist.github.com/cyberang3l/422a77a47bdc15a0824d5cca47e64ba2

kaczmarj avatar May 17 '20 04:05 kaczmarj

Thanks @kaczmarj, those are some helpful leads.

pwighton avatar May 19 '20 03:05 pwighton

Hi @pwighton,

I also tried to get freeview to work and I have a solution that now works well with singularity - but maybe some of the changes I made are also helpful for you running it in docker with vnc. I submitted a pull request where I left 'lib/qt' intact and I added libqt5widgets5 libqt5x11extras5 libglu1-mesa qt5-default libqt4-scripttools libqt4-opengl libxss1 libxft2 libjpeg62 libegl1-mesa libqt5dbus5 (after lot's of trial error). I found this to work best in ubuntu:16.04 - there is a little font problem in centos:6 that haven't figured out yet :p

stebo85 avatar May 22 '20 07:05 stebo85

Thanks @stebo85. Out of curiosity, does the machine you're running the container on have a GPU?

On Fri, May 22, 2020, 03:50 Steffen Bollmann [email protected] wrote:

Hi @pwighton https://github.com/pwighton,

I also tried to get freeview to work and I have a solution that now works well with singularity - but maybe some of the changes I made are also helpful for you running it in docker with vnc. I submitted a pull request where I left 'lib/qt' intact and I added libqt5widgets5 libqt5x11extras5 libglu1-mesa qt5-default libqt4-scripttools libqt4-opengl libxss1 libxft2 libjpeg62 libegl1-mesa libqt5dbus5 (after lot's of trial error). I found this to work best in ubuntu:16.04 - there is a little font problem in centos:6 that haven't figured out yet :p

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ReproNim/neurodocker/issues/343#issuecomment-632551010, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIONO5FFWMJBEQTZDDWXCTRSYVDPANCNFSM4NBF5HOA .

pwighton avatar May 23 '20 14:05 pwighton

@pwighton: yes, the machine has a GPU

stebo85 avatar May 25 '20 04:05 stebo85

Hi @pwighton was you successful to run freeview inside docker with vncserver? I have launched freeview, but it doesn't use GPU, however I tun it throught vglrun, and access --gpus all resources for docker.

relyativist avatar Aug 07 '20 16:08 relyativist

Thanks @relyativist, I haven't had much time since to try to get it working.

pwighton avatar Aug 18 '20 17:08 pwighton

@pwighton - if this solved your problem? can we close the issue?

djarecka avatar Feb 17 '23 20:02 djarecka

I've moved on to using neurodesk for getting FreeView in a container. Ok with me to close.

pwighton avatar Feb 17 '23 23:02 pwighton