Skip to content

Upgrade WhipperSnapPy from 1.3 to 2.1, simplify and streamline integration#795

Merged
m-reuter merged 7 commits intoDeep-MI:devfrom
ClePol:whippersnappy_bump
Mar 9, 2026
Merged

Upgrade WhipperSnapPy from 1.3 to 2.1, simplify and streamline integration#795
m-reuter merged 7 commits intoDeep-MI:devfrom
ClePol:whippersnappy_bump

Conversation

@ClePol
Copy link
Member

@ClePol ClePol commented Feb 26, 2026

Overview

Upgrade to whippersnappy 2.0 with native EGL headless rendering, eliminating xvfb dependency and reducing Docker image size.

Changes

  • Direct data passing: Surface and overlay data passed in-memory instead of via disk I/O for better performance.
  • Validation checks: Added whippersnappy >= 2.0 version validation with clear error messages for users.
  • Removed xvfb & dependencies: Eliminated virtual framebuffer orchestration and X11-related libraries from Docker image.

Detailed Changes

  1. pyproject.toml — Version pin updated

    • whippersnappy>=1.3.1whippersnappy>=2.1
  2. requirements.mac.txt — Version pin updated

    • whippersnappy>=1.3.1whippersnappy>=2.1
  3. run_fastsurfer.sh — Removed xvfb orchestration

    • Removed entire maybe_xvfb block (lines 767–794)
    • Removed glfw/OpenGL/whippersnappy.core import test
    • Removed all associated warning messages
    • Simplified line 1184 by removing "${maybe_xvfb[@]}" prefix from CC module command invocation
    • Removed obsolete comment about xvfb-run wrapping
    • Note: Whippersnappy 2.1 renders headlessly via mesa—no virtual framebuffer needed
  4. tools/Docker/Dockerfile — Slimmed runtime dependencies

    • Updated dependencies from: xvfb libglib2.0-0 libxkbcommon-x11-0 libgl1 libegl1 libfontconfig1 libdbus-1-3
    • To: libegl1 libgl1 libfontconfig1
    • Removed:
      • xvfb (virtual framebuffer, replaced by native EGL)
      • libglib2.0-0 (X11/GUI stack)
      • libxkbcommon-x11-0 (X11 keyboard)
      • libdbus-1-3 (D-Bus, X11-related)
    • Kept: libgl1 (OpenGL),libegl1 (EGL rendering),libfontconfig1 (font rendering for captions/colorbars)
  5. CorpusCallosum/shape/mesh.py — Updated import and API call

    • Removed import OpenGL.GL pre-check (whippersnappy 2.0 manages its own GL context)
    • Changed: from whippersnappy.core import snap1from whippersnappy import snap1 (new top-level import)
    • Removed the except Exception handler about xvfb (no longer relevant with MESA)
    • Updated snap1() call:
      • Positional first arg → mesh=
      • overlaypath=overlay= (new API parameter names)
      • viewmat= --> view= (API change)
  6. CorpusCallosum/cc_visualization.py — Updated version references

    • Help text and warning messages: whippersnappy>=1.3.1whippersnappy>=2.1
  7. CorpusCallosum/shape/postprocessing.py — Updated error messages

    • ImportError message: removed "glfw or OpenGL" (whippersnappy handles these internally)
    • Generic Exception message: replaced xvfb guidance with MESA/libmesa6 guidance

@ClePol
Copy link
Member Author

ClePol commented Feb 26, 2026

I just remembered that some other files might also need version bumps besides pyproject.toml like mac requirements. I think the other files are auto-generated?
It would be great if you could pick up from here, since I'm not so familiar with the install / dockerization of FastSurfer.

@dkuegler dkuegler changed the title WhipperSnapPy2 upgrade Upgrade WhipperSnapPy from 1.3 to 2.0, simplify and streamline integration Feb 26, 2026
@dkuegler dkuegler marked this pull request as ready for review February 26, 2026 20:01
@dkuegler dkuegler requested a review from Copilot February 26, 2026 20:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request upgrades the whippersnappy dependency from version 1.3 to 2.0, which introduces native EGL headless rendering capabilities. This eliminates the need for xvfb (virtual framebuffer) orchestration, simplifies the codebase, and reduces Docker image size by removing X11-related dependencies.

Changes:

  • Upgraded whippersnappy version requirement from >=1.3.1 to >=2.0 across all dependency files
  • Removed xvfb orchestration logic and replaced with whippersnappy version validation in run_fastsurfer.sh
  • Refactored mesh snapshot generation to use whippersnappy 2.0's in-memory API instead of disk-based I/O
  • Reduced Docker runtime dependencies by removing xvfb and X11-related libraries (libglib2.0-0, libxkbcommon-x11-0, libdbus-1-3)

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pyproject.toml Updated whippersnappy version constraint in qc optional dependencies
requirements.mac.txt Updated whippersnappy version constraint for macOS builds
tools/Docker/Dockerfile Removed X11 dependencies and renamed variable to reflect EGL-based rendering
run_fastsurfer.sh Replaced xvfb orchestration with version validation logic, added error handling for version mismatches
CorpusCallosum/shape/mesh.py Updated API to use whippersnappy 2.0's direct data passing, added version check, updated imports
CorpusCallosum/shape/postprocessing.py Simplified mesh processing and updated error messages for EGL rendering
CorpusCallosum/cc_visualization.py Updated version references and adapted to new API signature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dkuegler dkuegler force-pushed the whippersnappy_bump branch 2 times, most recently from cfd458e to 2e42cff Compare March 2, 2026 14:55
@dkuegler dkuegler marked this pull request as draft March 2, 2026 15:01
@dkuegler dkuegler marked this pull request as draft March 2, 2026 15:01
@dkuegler dkuegler force-pushed the whippersnappy_bump branch from 2e42cff to 4a694e3 Compare March 3, 2026 14:28
@dkuegler dkuegler force-pushed the whippersnappy_bump branch from 7615cc9 to 94bd496 Compare March 9, 2026 08:00
@m-reuter
Copy link
Member

m-reuter commented Mar 9, 2026

Note, in version 2.1 we will turn around again to using EGL. This is currently being tested in fsqc. My testing is complete. The reasons:

  1. when logged in via ssh on a workstation with NVIDIA GPU, the missing DISPLAY would result in a fallback to osMesa which is usually not installed -> no rendering possible, even though EGL is installed and would work with GPU.
  2. I realised that EGL also as CPU off screen rendering capabilities. This is now implemented. EGL is the more modern way to go and (opposed to osMesa) supports both GPU and CPU based rendering directly. Furthermore, it is more frequently already installed.

So here we need to update Docker to add only these three libraries for Whippersnappy:

    libegl1 \
    libgl1 \
    libfontconfig1 && \

Depending on the base image, one needs additional settings when enabling --gpus all for GPU support via EGL inside docker. See:

https://github.com/Deep-MI/WhipperSnapPy/blob/main/Dockerfile

But this is not necessary as it will fall back to EGL CPU based rendering. Singularity --nv works out of the box.

@dkuegler dkuegler force-pushed the whippersnappy_bump branch 2 times, most recently from 38b0f39 to 4fa1bbc Compare March 9, 2026 15:41
…o 2.1:

1. pyproject.toml — Version pin updated
whippersnappy>=1.3.1 → whippersnappy>=2.1
2. requirements.mac.txt — Version pin updated
whippersnappy>=1.3.1 → whippersnappy>=2.1
3. run_fastsurfer.sh — Removed xvfb orchestration (lines 767–794 removed, line 1184 simplified)
Removed the entire maybe_xvfb block: xvfb-run detection, the glfw/OpenGL/whippersnappy.core import test, and all associated warning messages. Whippersnappy 2.1 renders headlessly via native EGL — no virtual framebuffer needed.
Removed "${maybe_xvfb[@]}" prefix from the CC module command invocation.
Removed the obsolete comment about xvfb-run wrapping.
4. tools/Docker/Dockerfile — Slimmed runtime dependencies
whippersnappy_opengl_deps="xvfb libglib2.0-0 libxkbcommon-x11-0 libgl1 libegl1 libfontconfig1 libdbus-1-3" → whippersnappy_egl_deps="libegl1 libgl1 libfontconfig1"
Removed: xvfb (virtual framebuffer, replaced by native EGL), libglib2.0-0 (X11/GUI stack), libxkbcommon-x11-0 (X11 keyboard), libdbus-1-3 (D-Bus, X11-related)
Kept: libegl1 (EGL rendering), libgl1 (OpenGL), libfontconfig1 (font rendering for captions/colorbars)
5. CorpusCallosum/shape/mesh.py — Updated import and API call
Removed import OpenGL.GL pre-check (whippersnappy 2.1 manages its own GL context)
Changed from whippersnappy.core import snap1 → from whippersnappy import snap1 (new top-level import)
Removed the except Exception handler about xvfb (no longer relevant with EGL)
Updated snap1() call: positional first arg → mesh=, overlaypath= → overlay= (new API parameter names)
6. CorpusCallosum/cc_visualization.py — Updated version references
Help text and warning messages: whippersnappy>=1.3.1 → whippersnappy>=2.1
7. CorpusCallosum/shape/postprocessing.py — Updated error messages
ImportError message: removed "glfw or OpenGL" (whippersnappy handles these internally)
Generic Exception message: replaced xvfb guidance with EGL/libegl1 guidance
@dkuegler dkuegler force-pushed the whippersnappy_bump branch from 4fa1bbc to 207e722 Compare March 9, 2026 15:46
@m-reuter m-reuter changed the title Upgrade WhipperSnapPy from 1.3 to 2.0, simplify and streamline integration Upgrade WhipperSnapPy from 1.3 to 2.1, simplify and streamline integration Mar 9, 2026
dkuegler added 5 commits March 9, 2026 17:21
◦
Detects if --thickness_image flag is present in cc_flags (which is set when the user uses --qc_snap)
◦
Checks whether the whippersnappy Python package is installed and >2.1
◦
Raises an error and gives instruction if this is not the case.
…face and overlay files.

Use direct passing of the surface and overlay data instead of writing the files to disc first.
Remove and simplify commands, arguments and the like that are a relict of older whippersnappy versions, now fully requiring whippersnappy 2.
replace libegl with libmesa in docker for no-gpu rendering
- Pass the correct segmentation file into fastsurfer_cc
- Make reduce_to_aseg in reduce_to_aseg.py NOT be silently an inplace operation
- Clean up typing in CorpusCallosum/paint_into_pred.py
@dkuegler dkuegler force-pushed the whippersnappy_bump branch from 207e722 to 02140a4 Compare March 9, 2026 16:22
@dkuegler
Copy link
Member

dkuegler commented Mar 9, 2026

Note, in version 2.1 we will turn around again to using EGL. This is currently being tested in fsqc. My testing is complete. The reasons:

1. when logged in via ssh on a workstation with NVIDIA GPU, the missing DISPLAY would result in a fallback to osMesa which is usually not installed -> no rendering possible, even though EGL is installed and would work with GPU.

2. I realised that EGL also as CPU off screen rendering capabilities. This is now implemented. EGL is the more modern way to go and (opposed to osMesa) supports both GPU and CPU based rendering directly. Furthermore, it is more frequently already installed.

So here we need to update Docker to add only these three libraries for Whippersnappy:

    libegl1 \
    libgl1 \
    libfontconfig1 && \

Depending on the base image, one needs additional settings when enabling --gpus all for GPU support via EGL inside docker. See:

https://github.com/Deep-MI/WhipperSnapPy/blob/main/Dockerfile

But this is not necessary as it will fall back to EGL CPU based rendering. Singularity --nv works out of the box.

These is 1 thing that we currently do not have in FastSurfer:

  • update of /usr/share/glvnd/egl_vendor.d/10_nvidia.json

@m-reuter m-reuter marked this pull request as ready for review March 9, 2026 18:44
@m-reuter m-reuter merged commit 344eea5 into Deep-MI:dev Mar 9, 2026
2 checks passed
@m-reuter
Copy link
Member

These is 1 thing that we currently do not have in FastSurfer:

  • update of /usr/share/glvnd/egl_vendor.d/10_nvidia.json

Without it, my Docker would not recognise the GPUs (am using python slim as base)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants