Xvfb is a tool to run applications on a headless system (like the Biowulf cluster) with a virtual graphics framebuffer. Some applications require an X graphics framebuffer to render to, even if they are only producing a file as output. Xvfb automatically starts up a minimal X server to allow these applications to render graphics successfully.
Xvfb
(see the modules page for more information)xvfb-run
can be added in front of any command to run it in a context with a virtual X server.xvfb-run
command runs in a Singularity container, so you need to provide an absolute path to
your executable file. In Bash, you can do this by replacing program
with `which program`
.Allocate an interactive session and run the program. Sample session (user input in bold):
For this example, we use the Python package ETE3/etetoolkit which requires an X server for rendering phylogenetic trees with QT. To run this example you would need to set up a working Mamba install.
[user@biowulf ~]$ sinteractive --gres=lscratch:10 salloc: Pending job allocation 49701034 salloc: job 49701034 queued and waiting for resources salloc: job 49701034 has been allocated resources salloc: Granted job allocation 49701034 salloc: Waiting for resource configuration salloc: Nodes cn4335 are ready for job srun: error: x11: no local DISPLAY defined, skipping error: unable to open file /tmp/slurm-spank-x11.49701034.0 slurmstepd: error: x11: unable to read DISPLAY value [user@cn4335 ~]$ cd /lscratch/$SLURM_JOB_ID [user@cn4335 49701034]$ mamba create -qyn ete ete3 [user@cn4335 49701034]$ conda activate ete [user@cn4335 49701034]$ python -c 'from ete3 import Tree; t = Tree( "((a,b),c);" ); t.render("tree.pdf")' qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, webgl, xcb. Aborted [user@cn4335 49701034]$ module load Xvfb [user@cn4335 49701034]$ xvfb-run `which python` -c 'from ete3 import Tree; t = Tree( "((a,b),c);" ); t.render("tree.pdf")' QStandardPaths: error creating runtime directory '/run/user/936' (Read-only file system) [user@cn4335 49701034]$ ls -la tree.pdf -rw-r--r-- 1 user user 8221 Oct 13 10:36 tree.pdf
Create a batch input file (e.g. render.sh). For example:
#!/bin/bash set -e module load Xvfb xvfb-run `which python` -c 'from ete3 import Tree; t = Tree( "((a,b),c);" ); t.render("tree.pdf")'
Submit this job using the Slurm sbatch command.
sbatch render.sh