Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load folders for labeling in napari-dlc #2338

Closed
2 tasks done
Andrianarivelo opened this issue Aug 1, 2023 · 6 comments
Closed
2 tasks done

Unable to load folders for labeling in napari-dlc #2338

Andrianarivelo opened this issue Aug 1, 2023 · 6 comments
Assignees
Labels
GUI issues relating to GUI Installation

Comments

@Andrianarivelo
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Bug description

Hello,

I am struggling with the new labeling GUI, I upgraded DLC to version 2.3.5, and when I load config.yaml, images or h5 data file by dropping them directly onto the canvas or via the File menu absolutely nothing happens. I extracted frames before, and I used DLC 2.2 for years but we find the new GUI really annoying. Same when I do deeplabcut.label_frames(config_path), nothing happens and I get the same log output.

Operating System

Ubuntu 20.04.4

DeepLabCut version

dlc version 2.3.5

DeepLabCut mode

single animal

Device type

gpu Nvidia 3090/

Steps To Reproduce

In DLC environment
napari
drop a folder from DeepLabCut's project labeled-data

Relevant log output

Installed qt6 event loop hook.
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast

WARNING: QOpenGLWidget: Failed to create context
11:46:05 WARNING QOpenGLWidget: Failed to create context
WARNING: QOpenGLWidget: Failed to create context
11:46:05 WARNING QOpenGLWidget: Failed to create context
WARNING: QOpenGLWidget: Failed to create context
11:46:05 WARNING QOpenGLWidget: Failed to create context
WARNING: QOpenGLWidget: Failed to create context
11:46:05 WARNING QOpenGLWidget: Failed to create context
WARNING: composeAndFlush: QOpenGLContext creation failed
11:46:05 WARNING composeAndFlush: QOpenGLContext creation failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:05 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed
11:46:07 WARNING composeAndFlush: makeCurrent() failed
WARNING: composeAndFlush: makeCurrent() failed

Anything else?

No response

Code of Conduct

@n-poulsen
Copy link
Collaborator

Hi @Andrianarivelo, could you please let us know which version of napari you're using? You can do this by running napari --info in the conda environment you use for DeepLabCut.

The full output would be useful to us (so we can see which package versions are installed and being used).

@n-poulsen n-poulsen added the GUI issues relating to GUI label Aug 7, 2023
@Andrianarivelo
Copy link
Author

Andrianarivelo commented Aug 9, 2023

Hi, thanks for the response, here's what I get after napari --info:

libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
napari: 0.4.18
Platform: Linux-5.19.0-46-generic-x86_64-with-glibc2.35
System: Ubuntu 22.04.2 LTS
Python: 3.9.16 (main, Mar  8 2023, 14:00:05)  [GCC 11.2.0]
Qt: 6.3.1
PySide6: 
NumPy: 1.23.0
SciPy: 1.9.1
Dask: 2023.4.0
VisPy: 0.12.2
magicgui: 0.7.2
superqt: unknown
in-n-out: 0.1.7
app-model: 0.1.4
npe2: 0.7.0

OpenGL:
  - GL version:  
  - MAX_TEXTURE_SIZE: ()

Screens:
  - screen 1: resolution 2560x1440, scale 1.0
  - screen 2: resolution 2560x1440, scale 1.0
  - screen 3: resolution 1024x1280, scale 1.0

Settings path:
  - /home/locorungs/.config/napari/dlc232_d6243d3e7659f8234b764406578ffc7da0900f54/settings.yaml
Plugins:
  - napari: 0.4.18 (77 contributions)
  - napari-console: 0.0.8 (0 contributions)
  - napari-deeplabcut: 0.2.0 (16 contributions)
  - napari-svg: 0.1.10 (2 contributions)

@n-poulsen
Copy link
Collaborator

The root issue seems to be with libGL: libGL error: failed to load driver: swrast. Most likely, that is why the GUI is not working.

I've found this post describing a similar issue, and some comments with ways to install libGL correctly. Could you try these solutions and let me know if this works for you?

I believe the easiest that might work would be running sudo apt-get install libgl1-mesa-dri.

As long as you get this libGL error: failed to load driver: swrast error message when running napari --info, I think the GUI will not work.

@Andrianarivelo
Copy link
Author

Andrianarivelo commented Aug 10, 2023

Thanks a lot, I fixed it with sudo apt-get install libgl1-mesa-dri, creating /usr/lib/dri/, then copy swrast_dri.so in it with sudo cp /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so /usr/lib/dri

But then I got : libGL error: MESA-LOADER: failed to open swrast: /home/locorungs/.conda/envs/dlc232/bin/../lib/libstdc++.so.6: version GLIBCXX_3.4.30' not found (required by /lib/x86_64-linux-gnu/libLLVM-15.so.1) (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)

I fixed it by updating libstdc++ with sudo apt-get install libstdc++6 and sudo cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ~/.conda/envs/dlc232/lib

The GUI works and I can load folders now

@Andres9713
Copy link

Andres9713 commented Nov 20, 2023

I wanted to follow up on this because I spent most of the weekend trying to get deeplabcut installed, and most of that time trying to deal with this 'swrast' issue. In my case I was trying to (and now succeeded in) getting DLC installed in an Ubuntu 20.04 LXC container with NVidia GPU passthrough (running on an Ubuntu 22.04 host). The .yaml conda install failed due to some tensorflow issues I couldn't solve - I also couldn't get docker running (apparently this works better in privileged container which mine are not). I ended up copying the following installation recipe #2140 (comment) which got me a lot closer to a working state. The last hurdle though was the following error message (which may be related to the way NVIDIA GPU passthrough works on LXC).

Loading DLC 2.3.8...
Starting GUI...
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/x86_64-linux-gnu/libLLVM-12.so.1: undefined symbol: ffi_type_sint32, version LIBFFI_BASE_7.0 (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast

At this point the GUI starts but much of it is broken. The key to getting around this specific issue is was to delete the $CONDA_PREFIX/lib versions of libffi.so.7 and libffi.7.so and have them instead loaded in a different clunky way. I am including my entire install 'recipe' so someone else can save the time of having to start this process from scratch. I've now tested this on two separate Ubuntu 20.04 containers (on the same host) and have been able to run DLC using my NVIDIA GPU. Note that this is probably a result of a specific combination of issues (again, maybe LXC GPU passthrough) and I would certainly recommend trying the standard (conda yaml) install before this one.

install cuda 11.8 and cudnn 8.7 (see: https://www.enablegeek.com/blog/setting-up-cuda-and-cudnn-on-ubuntu-20-04/  and https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html)
CUDA:

sudo apt update
wget  https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run --toolkit --silent --override
export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc

CUDNN:

cd ~/Downloads
sudo dpkg -i cudnn-local-repo-ubuntu2004-8.7.0.84_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-<em>/cudnn-local-</em>-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install libcudnn8=8.7.0.84-1+cuda11.8
sudo apt-get install libcudnn8-dev=8.7.0.84-1+cuda11.8
sudo apt-get install libcudnn8-samples=8.7.0.84-1+cuda11.8

Probably restart your container/machine at this point for good measure.

'Manually' install DLC in conda environment:

conda create -n dlc python=3.8
conda activate dlc
conda install -c conda-forge ffmpeg
pip install "deeplabcut[gui,tf]"
conda install -c conda-forge cudatoolkit=11.8.0
python3 -m pip install nvidia-cudnn-cu11==8.6.0.163 tensorflow==2.12.*

Note this is part of the trick for getting around the 'swrast' issue, the last part of this fix is below I doubt the order of these operations matters, but this in fact the order I did them in:

pip install tensorrt --no-cache-dir 
cd $CONDA_PREFIX/lib/python3.8/site-packages/tensorrt_libs
ln -s libnvinfer.so.8 libnvinfer.so.7
ln -s libnvinfer_plugin.so.8 libnvinfer_plugin.so.7

Continuing with setting up this environment:

mkdir -p $CONDA_PREFIX/etc/conda/activate.d
echo 'CUDNN_PATH=$(dirname  $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/python3.8/site-packages/tensorrt_libs' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
mkdir -p $CONDA_PREFIX/etc/conda/deactivate.d
echo 'unset LD_LIBRARY_PATH' >> $CONDA_PREFIX/etc/conda/deactivate.d/env_vars.sh
source $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh

To resolve the 'drawtype' bug:
pip install matplotlib==3.6.3

For using Jupyter Notebook:
pip install jupyter notebook

Last part of fixing the swrast issue (credit to this github commenter spinalcordtoolbox/spinalcordtoolbox#3927 (comment)):

- cd $CONDA_PREFIX/lib
- mv libffi.so.7 libffi.so.7.bak
- mv libffi.7.so libffi.7.so.bak

Note that conda updates could end up recreating these problematic '.so' files, so the issue would come back - if anyone knows of a better solution (that they have actually validated) please let me know - I tried very many of the other suggestion I came across on this subject, including those in the previous comments on this issue page, but it was this combination that got things unstuck. Hopefully this saves someone a weekend sometime down the road.

@Ashu156
Copy link

Ashu156 commented Jan 22, 2024

Hi, I am also having the same issue as describe by Andrianarivelo here. I am using DLC 2.3.4 on Ubuntu 20.04.

However, when i am running napari --info, I get the following:
libEGL warning: DRI3: Screen seems not DRI3 capable
libEGL warning: DRI2: failed to authenticate
napari: 0.4.17
Platform: Linux-6.2.0-39-generic-x86_64-with-glibc2.35
System: Ubuntu 22.04.2 LTS
Python: 3.10.11 (main, Apr 20 2023, 19:02:41) [GCC 11.2.0]
Qt: 6.3.1
PySide6:
NumPy: 1.23.5
SciPy: 1.10.1
Dask: 2023.4.1
VisPy: 0.11.0
magicgui: 0.7.2
superqt: unknown
in-n-out: 0.1.7
app-model: 0.1.4
npe2: 0.7.0

OpenGL:

  • GL version:
  • MAX_TEXTURE_SIZE: ()

Screens:

  • screen 1: resolution 1920x1080, scale 1.0

Plugins:

  • napari: 0.4.17 (77 contributions)
  • napari-console: 0.0.8 (0 contributions)
  • napari-deeplabcut: 0.1.2 (16 contributions)
  • napari-svg: 0.1.6 (2 contributions)

Please suggest the required solution to get around this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI issues relating to GUI Installation
Projects
None yet
Development

No branches or pull requests

4 participants