napari / napari

napari: a fast, interactive, multi-dimensional image viewer for python
https://napari.org
BSD 3-Clause "New" or "Revised" License
2.19k stars 422 forks source link

napari freeze - QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled #7329

Open romainGuiet opened 6 days ago

romainGuiet commented 6 days ago

šŸ› Bug Report

when starting napari I get a frozen napari window displaying the terminal and the following error :

(napari) biop@c79840740ddb:~$ napari
WARNING: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-biop'
08:49:29 : WARNING : MainThread : QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-biop'
WARNING: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
08:49:29 : WARNING : MainThread : QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
WARNING: QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled
08:49:29 : WARNING : MainThread : QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled
WARNING: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
08:49:32 : WARNING : MainThread : QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
WARNING: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
08:49:32 : WARNING : MainThread : QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
WARNING: composeAndFlush: QOpenGLContext creation failed

šŸ’” Steps to Reproduce

  1. build a docker image with the docker file :

ARG ALIAS=biop/ ARG BASE_IMAGE=0.1.0 FROM ${ALIAS}biop-vnc-base:${BASE_IMAGE}

USER root

create napari env

RUN conda create --name napari napari=0.5.4 pyqt -c conda-forge -y

RUN chown -R biop:biop /home/biop/ \ && chmod -R a+rwx /home/biop/

#################################################################

Container start

USER biop WORKDIR /home/biop ENTRYPOINT ["/usr/local/bin/jupyter"] CMD ["lab", "--allow-root", "--ip=", "--port=8888", "--no-browser", "--NotebookApp.token=''", "--NotebookApp.allow_origin=''", "--notebook-dir=/home/biop"]


2. start the image, follow the link to http://localhost:8888/lab
3. click on VNC icon , to start the desktop
4. start a terminal
5. type `source activate napari`
6. type napari
7. get the error

### šŸ’” Expected Behavior

napari window should pop-up normally 

### šŸŒŽ Environment

not working env : [napari_notworking.txt](https://github.com/user-attachments/files/17343548/napari_notworking.txt)

working env old version (0.4.18) of napari with devbio-napari [devbio_working.txt](https://github.com/user-attachments/files/17343551/devbio_working.txt)

### šŸ’” Additional Context

Thank you for any suggestion you might have

Cheers,

Romain 
psobolewskiPhD commented 6 days ago

I'm not sure I follow: are you saying the dockerfile works with napari 0.4.19 but not with 0.5.4, with everything else being held the same?

Czaki commented 5 days ago

For me, it looks like lack of OpenGL libraries.

psobolewskiPhD commented 5 days ago

I think something changed in your container image so you don't have the libxcb libs needed. Here's what we use on napari CI: https://github.com/tlambert03/setup-qt-libs I guess it's possible that installing qt from conda-forge pulled some of these and that's changed? But I think it must be your container.

romainGuiet commented 2 days ago

Dear @psobolewskiPhD , Dear @Czaki ,

Thank you for your answers.

I'm sorry if my description was not clear enough , I will try to explain better below:

are you saying the dockerfile works with napari 0.4.19 but not with 0.5.4, with everything else being held the same?

Using the docker file below, I created an image that contains the pre-existing working napari and a newly created non-working, respectively in the left and right of the screenshot below .

ARG ALIAS=biop/
ARG BASE_IMAGE=0.1.1
FROM ${ALIAS}biop-vnc-base:${BASE_IMAGE}

USER root

##############################################################################
# install devbio-napari
# COPY devbio/env_devbio.yml /tmp/env_devbio.yml
# RUN mamba env create -n devbio -f /tmp/env_devbio.yml \
#     && conda clean --all -f -y \
#     && conda env export -n "biop" \
#      && rm /tmp/env_devbio.yml

# create doesn't work
RUN conda create --name napari napari=0.5.4 pyqt -c conda-forge -c pytorch -y
#################################################################
# from copy it works
COPY --from=biop/biop-devbio:0.10.1 /opt/conda/envs/devbio /opt/conda/envs/devbio

#################################################################
RUN chown -R biop:biop /home/biop/ \
&& chmod -R a+rwx /home/biop/ 

#################################################################
# Container start
USER biop
WORKDIR /home/biop
ENTRYPOINT ["/usr/local/bin/jupyter"]
CMD ["lab", "--allow-root", "--ip=*", "--port=8888", "--no-browser", "--NotebookApp.token=''", "--NotebookApp.allow_origin='*'", "--notebook-dir=/home/biop"]

image

Therefore, I'm not sure that this issue is a container issue.

Nevertheless the two environments are not with everything else being held the same. Indeed, if you compare napari_notworking.txt with devbio_working.txt there are a lot of differences.

For me, it looks like lack of OpenGL libraries.

I'll have a look

Here's what we use on napari CI: https://github.com/tlambert03/setup-qt-libs

I'll look at it too

Thanks again for your inputs, shall you have any other ideas do not hesitate !

Cheers

Romain

psobolewskiPhD commented 2 days ago

Just to be sure if this is a napari 0.5.x issue, you try to also check:

RUN conda create --name napari napari=0.4.19 pyqt -c conda-forge -c pytorch -y

If that also fails, then I assume that your container here:

COPY --from=biop/biop-devbio:0.10.1 /opt/conda/envs/devbio /opt/conda/envs/devbio

has something that is otherwise missing. Probably something from the list of setup-qt-libs.

If 0.4.19 works, then it may point to the restructuring of the napari-feedstock by Jaime here: https://github.com/conda-forge/napari-feedstock/pull/63