Skip to content

Add Modal.com GPU server for nnInteractive v2 + fix macOS pip crash - #98

Draft
pieper wants to merge 4 commits into
coendevente:mainfrom
pieper:nninteractive-v2-modal
Draft

Add Modal.com GPU server for nnInteractive v2 + fix macOS pip crash#98
pieper wants to merge 4 commits into
coendevente:mainfrom
pieper:nninteractive-v2-modal

Conversation

@pieper

@pieper pieper commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • server/modal_app.py — new Modal.com deployment that serves nnInteractive v2 as a drop-in replacement for the local server at port 1527. Point the Slicer extension at the Modal URL instead of http://localhost:1527.
  • SlicerNNInteractive.py — fix macOS crash when installing dependencies: slicer.util.pip_install creates Qt dialogs from a background thread, which crashes on macOS because NSWindow must be created on the main thread. Replaced with subprocess.check_call running pip directly on the main thread.

Modal server changes from the upstream v1 server

  • nninteractive upgraded 1.0.1 → 2.4.2
  • use_pinned_memory removed (replaced by interactions_storage='auto' in v2)
  • interaction_bbox added to lasso/scribble calls (~1000x speedup by limiting inference to the drawn region)
  • /health and /reset endpoints added
  • Model weights cached in a persistent Modal Volume (no re-download on container restart)
  • container_idle_timeout=360 keeps the container alive during a session
  • allow_concurrent_inputs=1 serializes requests to protect in-memory session state

Backward compatibility

The HTTP API shape is identical between the v1 and v2 servers — all existing endpoints (/upload_image, /upload_segment, /add_point_interaction, /add_bbox_interaction, /add_lasso_interaction, /add_scribble_interaction) use the same request/response formats. The Slicer plugin works unchanged against either server.

Test plan

  • modal serve server/modal_app.py starts without errors
  • Point Slicer extension at the ephemeral Modal URL; upload image and confirm all prompt types (point, bbox, lasso, scribble) return correct segmentations
  • modal deploy server/modal_app.py produces a persistent URL
  • Confirm macOS no longer crashes during first-run dependency install

🤖 Generated with Claude Code

@pieper

pieper commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Addresses #96

pieper and others added 4 commits June 29, 2026 17:55
slicer.util.pip_install called from a background thread triggers Qt
dialog creation off the main thread, which crashes on macOS because
NSWindow must be created on the main thread.  Run pip directly via
subprocess.check_call on the main thread instead.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
modal_app.py is a drop-in replacement for the local server at port 1527.
Key changes from the upstream v1 server:
- nninteractive upgraded 1.0.1 → 2.4.2
- use_pinned_memory replaced by interactions_storage='auto'
- interaction_bbox added to lasso/scribble calls (3-orders-of-magnitude speedup)
- /health and /reset endpoints added
- Model weights cached in a persistent Modal Volume (no re-download on restart)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
conda create with --override-channels does not install pip by default;
adding it explicitly ensures the subsequent pip uninstall/install steps
can run.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@pieper
pieper force-pushed the nninteractive-v2-modal branch from e7d2bbb to 86a3ecb Compare June 29, 2026 21:55
@pieper
pieper marked this pull request as draft June 29, 2026 22:23
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.

1 participant