talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
435 stars 97 forks source link

Running SLEAP headless #1926

Closed agosztolai closed 2 months ago

agosztolai commented 2 months ago

Hello,

I am trying to run SLEAP on a remote server that does not have displays installed.

I can install SLEAP without issues using conda. However, when I want to import sleap in python I get the following error.

>>> import sleap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/msc/home/agoszt25/sleap/sleap/__init__.py", line 10, in <module>
    from sleap.io.dataset import Labels, load_file
  File "/msc/home/agoszt25/sleap/sleap/io/dataset.py", line 83, in <module>
    from sleap.gui.dialogs.missingfiles import MissingFilesDialog
  File "/msc/home/agoszt25/sleap/sleap/gui/dialogs/missingfiles.py", line 10, in <module>
    from qtpy import QtWidgets, QtCore, QtGui
  File "/msc/home/agoszt25/miniconda3/envs/sleap/lib/python3.7/site-packages/qtpy/QtWidgets.py", line 111, in <module>
    from PySide2.QtWidgets import *
  File "/msc/home/agoszt25/miniconda3/envs/sleap/lib/python3.7/site-packages/shiboken2/files.dir/shibokensupport/feature.py", line 139, in _import
    return original_import(name, *args, **kwargs)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Do you know how to resolve this issue? Can SLEAP be run in 'headless' mode?

roomrys commented 2 months ago

Hi @agosztolai,

We have run into this ourselves recently due to this change in the opencv package being pulled in: https://github.com/conda-forge/opencv-feedstock/issues/401 which no longer comes shipped with required GUI libraries. This causes issues on Linux machines, but there is a quick fix.

The SLEAP package is very intertwined with it's GUI code (hence why we are slowly but surely modularizing parts into their own packages - see sleap-io and sleap-nn). Even if you do not need the GUI, you will need to install the following packages: https://github.com/talmolab/sleap/blob/dc78ee842774777d6645d6951a008761d78744ce/.github/workflows/ci.yml#L69-L70

Let us know if you run into any trouble.

Thanks, Liezl

agosztolai commented 2 months ago

Hi Liezl,

Thank you for the feedback. Unfortunately, I do not have sudo access on the server so I cannot run the commands that you suggest.

I have tried finding these packages compatible with conda environments, installed them, namely

https://anaconda.org/anaconda/mesa-libegl-devel-cos6-x86_64 https://anaconda.org/conda-forge/mesa-libglapi-cos7-x86_64 https://anaconda.org/conda-forge/mesalib https://anaconda.org/conda-forge/libopengl

However, this didn’t help.

I also want to note that the problem seem to be not only with CV2, but Qt too. For example, installing pip install opencv-python-headless solves the issue with opencv. But the Qt is still looking for the libel.so.1 library, which I am not able to resolve.

Best, Adam

On 28.08.2024, at 20:24, Liezl Maree @.***> wrote:

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

We have run into this ourselves recently due to this change in the opencv package being pulled in: conda-forge/opencv-feedstock#401 https://github.com/conda-forge/opencv-feedstock/issues/401 which no longer comes shipped with required GUI libraries. This causes issues on Linux machines, but there is a quick fix.

The SLEAP package is very intertwined with it's GUI code (hence why we are slowly but surely modularizing parts into their own packages - see sleap-io https://github.com/talmolab/sleap-io and sleap-nn https://github.com/talmolab/sleap-nn). Even if you do not need the GUI, you will need to install the following packages: https://github.com/talmolab/sleap/blob/dc78ee842774777d6645d6951a008761d78744ce/.github/workflows/ci.yml#L69-L70

Let us know if you run into any trouble.

Thanks, Liezl

— Reply to this email directly, view it on GitHub https://github.com/talmolab/sleap/issues/1926#issuecomment-2315996671, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK6WK5DYNOIC7S4RIM26L4TZTYIXHAVCNFSM6AAAAABNIM6B56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJVHE4TMNRXGE. You are receiving this because you were mentioned.

roomrys commented 2 months ago

Hi Adam,

I have two suggestions below and would try them one at a time starting with the first suggestion.


The believed issue/cause

I also want to note that the problem seem to be not only with CV2, but Qt too. For example, installing pip install opencv-python-headless solves the issue with opencv. But the Qt is still looking for the libel.so.1 library, which I am not able to resolve.

The opencv and Qt packages are closely intertwined. The issue we are facing comes from this conda-forge issue:

where they basically released newer builds of the same version of opencv that include qt6-main as a dependency which means they also added OpenGL libraries to the opencv package which seem to conflict with the packages that are needed with qt2 (which is what we are using). The previous build of SLEAP was released before they started adding these "breaking" opencv packages and hence we do not have a constrain on the newer opencvs yet, but are working on our new release in:


Pre-suggestions

I have tried finding these packages compatible with conda environments, installed them, namely https://anaconda.org/anaconda/mesa-libegl-devel-cos6-x86_64 https://anaconda.org/conda-forge/mesa-libglapi-cos7-x86_64 https://anaconda.org/conda-forge/mesalib https://anaconda.org/conda-forge/libopengl However, this didn’t help.

Oof, ok, there is possibility that our environment might be a little wonky with these extras installed - would you be ok with recreating the environment first before trying new suggestions?


Suggestion 1

Unfortunately, I do not have sudo access on the server so I cannot run the commands that you suggest.

Sorry! I should have suggested the following first as "with great power comes great responsibility". Can you run

apt-get install libglapi-mesa libegl-mesa0 libegl1 libopengl0 libgl1-mesa-glx

without the sudo?


Suggestion 2

Are you able to list the environment info with conda list while you are in your sleap environment. I am curious which opencv is being used. I wonder if this can be resolved by uninstalling opencv in your sleap environment

conda uninstall opencv

and then reinstalling (constraining to a version of opencv before the addition of the qt6-main dependency)

conda install -c conda-forge "opencv<=4.8.1"

Sorry for the trouble. Please let us know how it goes.

Thanks, Liezl

roomrys commented 2 months ago

Hi @agosztolai,

We have released SLEAP 1.3.4 (off https://github.com/talmolab/sleap/pull/1927) which adds additional dependency constraints to prevent this from happening.

If you are able, please upgrade to v1.3.4 and let us know if it solves your issue.

I am closing this for now, but if the problem persists, I will reopen the issue.

Thanks, Liezl