Project-MONAI / Project-MONAI/MONAI
Bug Report: MONAI Import Hangs on macOS with Apple Silicon (MPS)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.7k
- Forks
- 1.6k
- Avg merge
- 5d 1h
- Merged PRs (30d)
- 20
Description
Describe the bug
Importing MONAI causes a complete hang with a mutex lock error on macOS 15.7.3 (Apple Silicon). The process becomes unresponsive and must be force-terminated. The error message displayed is:
[mutex.cc : 452] RAW: Lock blocking 0x<address> @
To Reproduce
Steps to reproduce the behavior:
-
Environment Setup:
- macOS 15.7.3 (Build 24G419) on Apple Silicon
- Python 3.12.11
- Install MONAI 1.5.1 with PyTorch 2.6.0
-
Installation:
pip install monai==1.5.1 pip install torch==2.6.0 -
Run the minimal reproduction:
python3.12 -c "import monai; print('Monai imported')" -
Observe: The command hangs indefinitely with the mutex lock error message.
Expected behavior
The import should complete successfully and print "Monai imported" without hanging.
Environment
Since import monai hangs, I cannot run monai.config.print_debug_info(). Here's the environment information:
ProductName: macOS
ProductVersion: 15.7.3
BuildVersion: 24G419
Python: 3.12.11
Package Versions:
monai 1.5.1
torch 2.6.0
numpy 2.3.2
pytorch-lightning 2.5.2
Additional context
- The issue occurs immediately upon
import monai, before any MONAI functionality is used - The same environment can successfully import and use PyTorch with MPS acceleration for training
- Setting
PYTORCH_ENABLE_MPS_FALLBACK=1does not resolve the issue - Attempting to force CPU-only mode before import also fails
- The issue persists across both MONAI 1.5.0 and 1.5.1
- Other PyTorch-based libraries (pytorch-lightning, segmentation-models-pytorch) work correctly in the same environment
- The mutex lock appears to be related to multiprocessing/threading initialization within MONAI's dependencies
Workaround Attempted
Tried updating from MONAI 1.5.0 to 1.5.1 - issue persists.
Impact
This completely blocks the use of MONAI on Apple Silicon Macs with macOS 15.7.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is identified. First reproduce the hang with the documented Python 3.12/macOS Apple Silicon environment using the minimal import monai command, then trace MONAI's import-time dependency or threading initialization. Done means the command completes and prints "Monai imported" without hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, python, pytorch
- Domain
- machine-learning, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100