bidscoin icon indicating copy to clipboard operation
bidscoin copied to clipboard

[BUG] apptainer can't open bidsmapper GUI - missing dependency

Open bcmcpher opened this issue 1 year ago • 5 comments

I followed the instructions here for using bidsmapper from a singularity container. However, I receive the following error:

INFO | Opening the bidseditor
qt.qpa.theme.dbus: Session DBus not running.
qt.qpa.theme.dbus: Application will not react to setting changes.
 Check your DBus installation.
dbus[114563]: D-Bus library appears to be incorrectly set up: see the manual page for dbus-uuidgen to correct this issue. (Failed to open "/var/lib/dbus/machine-id": No such file or directory; Failed to open "/etc/machine-id": No such file or directory)
  D-Bus not built with -rdynamic so unable to print a backtrace

To reproduce: Follow the tutorial instructions on the website in a clean environment.

> apptainer build bidscoin.sif docker://marcelzwiers/bidscoin:4.4.0  # results are the same with sudo
> xhost +
> apptainer exec bidscoin.sif bidsmapper dicom/ bids/

Expected behavior: bidsmapper GUI should open

Software version

  • Ubuntu 22.04 with X11 (Wayland is installed)
  • apptainer 1.1.9
  • BIDScoin 4.4.0

Potential Fix: If I set export QT_DEBUG_PLUGINS=1, I get a verbose log, with the only obvious error being:

qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/opt/miniconda-latest/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so" : "Cannot load library /opt/miniconda-latest/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so: libgtk-3.so.0: cannot open shared object file: No such file or directory"

I was unable to bind libqgtk3.so into that location from my host, but if I did a --sandbox build of the container, I was able to run apt install libqgtk-3-0, which added some dependencies. With those additional libraries I was able to launch the bidsmapper GUI.

I believe adding libqgtk-3-0 to the build instructions as part of the conda environment or w/ apt will fix this issue.

bcmcpher avatar Oct 18 '24 20:10 bcmcpher

That's strange, because it ran without issue on my Linux test VM. Maybe there has been an update of some dependency, causing this issue, I will have a look

marcelzwiers avatar Oct 24 '24 08:10 marcelzwiers

I did what you described to reproduce the issue, but my test ran normally:

$ apptainer exec bidscoin.sif bidscoin -t
INFO | --------- Testing the BIDScoin's core functionality ---------
INFO | Running bidsmap checks:
INFO | Reading: /home/marzwi/.bidscoin/4.4.0/templates/bidsmap_dccn.yaml
INFO | Checking the bidsmap run-items:
VERBOSE | Could not validate every run-item in the bidsmap
VERBOSE | Checking the template bidsmap datatypes:
SUCCESS | All datatypes and options in the template bidsmap are valid
INFO | Testing the PyQt GUI setup:
qt.qpa.theme.dbus: Session DBus not running.
qt.qpa.theme.dbus: Application will not react to setting changes.
 Check your DBus installation.
SUCCESS | The GUI seems to work OK
INFO | Testing the DRMAA setup:
WARNING | The DRMAA library could not be imported. This is OK if you want to run pydeface locally and not use the option to distribute jobs on a compute cluster
Could not find drmaa library.  Please specify its full path using the environment variable DRMAA_LIBRARY_PATH
INFO | Executable BIDScoin tools:
INFO | - bidscoin
INFO | - bidscoiner
INFO | - bidseditor
INFO | - bidsmapper
INFO | - bidsparticipants
INFO | - deface
INFO | - dicomsort
INFO | - echocombine
INFO | - fixmeta
INFO | - medeface
INFO | - physio2tsv
INFO | - plotphysio
INFO | - rawmapper
INFO | - skullstrip
INFO | - slicereport
INFO | Installed template bidsmaps (/home/marzwi/.bidscoin/4.4.0/templates):
INFO | - bidsmap_bids2bids
INFO | - bidsmap_dccn (default)
INFO | - bidsmap_sst
INFO | Installed plugins (/home/marzwi/.bidscoin/4.4.0/plugins):
INFO | - dcm2niix2bids
INFO | - nibabel2bids
INFO | - spec2nii2bids
INFO | --------- Testing the 'dcm2niix2bids' plugin ---------
INFO | Testing the dcm2niix2bids installation:
VERBOSE | Command:
dcm2niix -v
VERBOSE | Output:
Chris Rorden's dcm2niiX version v1.0.20240202  (JP2:OpenJPEG) (JP-LS:CharLS) GCC12.2.0 x86-64 (64-bit Linux)
v1.0.20240202

SUCCESS | The 'dcm2niix2bids' plugin functioned correctly
INFO | --------- Testing the 'nibabel2bids' plugin ---------
INFO | Testing the nibabel2bids installation:
INFO | Nibabel version: 5.2.1
SUCCESS | The 'nibabel2bids' plugin functioned correctly
INFO | --------- Testing the 'spec2nii2bids' plugin ---------
INFO | Testing the spec2nii2bids installation:
VERBOSE | Command:
spec2nii -v
VERBOSE | Output:
0.8.4

SUCCESS | The 'spec2nii2bids' plugin functioned correctly
SUCCESS | All tests finished successfully :-)

marcelzwiers avatar Oct 25 '24 09:10 marcelzwiers

@hurngchunlee Could you give it a try and see if you can successfully build and run a bidscoin container?

sudo apptainer build bidscoin.sif docker://marcelzwiers/bidscoin:4.4.0
xhost +
apptainer exec bidscoin.sif bidscoin -t

marcelzwiers avatar Oct 28 '24 11:10 marcelzwiers

@marcelzwiers I can reproduce the same error message as @bcmcpher reported. I tested it on my laptop running Arch Linux and a VM running Ubuntu 22.04 LTS. On both systems, I got the error:

dbus[254602]: D-Bus library appears to be incorrectly set up: see the manual page for dbus-uuidgen to correct this issue. (Failed to open "/var/lib/dbus/machine-id": No such file or directory; Failed to open "/etc/machine-id": No such file or directory)
  D-Bus not built with -rdynamic so unable to print a backtrace

For me, it can be fixed by adding the bind-mount to host's /var/lib/dbus/machine-id when running the apptainer:

apptainer exec -B /var/lib/dbus/machine-id:/var/lib/dbus/machine-id:ro bidscoin.sif bidscoin -t

hurngchunlee avatar Oct 28 '24 19:10 hurngchunlee

Btw, the python:3-slim Docker baseimage that I was using was recently upgraded to version 3.13, which was causing pip install failures. I now fixed the base image to version python:3.12-slim, so building an apptainer image from the definition file should now work again (instead of pulling and converting it from dockerhub)

marcelzwiers avatar Oct 29 '24 09:10 marcelzwiers

The problem seems to be related to wayland, so I created a new ubuntu VM and could reproduce the issue when running:

apptainer exec bidscoin.sif bidscoin -t

Strangely, it works fine if I sudo it:

sudo apptainer exec bidscoin.sif bidscoin -t

marcelzwiers avatar Oct 29 '24 16:10 marcelzwiers

I believe the root of the issue is the security model of Wayland, and that installing libgtk-3-0 is a workaround to get a fallback (XWayland) Qt-plugin to work. I also think that gtk has nothing to do with it, so instead I added dbus to the install (which also solves the issue, hopefully in a leaner and cleaner way). I uploaded a patched docker image to DockerHub, please re-open this issue if you still encounter problems...

Thanks a lot for reporting this issue!

N.B.: The Qt-Wayland plugin still fails to load, to get that to work you need to add and bind the Wayland display, e.g. like this:

apptainer exec --env WAYLAND_DISPLAY=$WAYLAND_DISPLAY --bind /run/user/$(id -u)/wayland-0:/run/user/$(id -u)/wayland-0 bidscoin.sif bidscoin -t

marcelzwiers avatar Oct 30 '24 12:10 marcelzwiers

It's fixed it for me, thanks!

bcmcpher avatar Oct 31 '24 17:10 bcmcpher