-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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