Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions micro_manager/adaptivity/global_adaptivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Note: All ID variables used in the methods of this class are global IDs, unless they have *local* in their name.
"""
import hashlib
import shutil
from copy import deepcopy
import sys
from typing import Dict
Expand Down Expand Up @@ -90,6 +91,20 @@ def __init__(
nbytes = (
self._global_number_of_sims * self._global_number_of_sims * itemsize
)
# Check if /dev/shm has enough space before attempting allocation.
# On some systems, /dev/shm is limited to 50% of RAM, which can cause
# a cryptic MPI internal error for large simulations.
_, _, shm_free = shutil.disk_usage("/dev/shm")
if nbytes > shm_free:
raise RuntimeError(
"Not enough space in /dev/shm to allocate the similarity distance matrix "
"for global adaptivity.\n"
" Required : {} B\n"
" Available: {} B\n"
"On some systems /dev/shm is limited to 50% of RAM. "
"Consider increasing /dev/shm size (e.g. `--shm-size` in Docker, or "
"`tmpfs` remount), or use local adaptivity instead.".format(nbytes, shm_free)
)
else:
nbytes = 0

Expand Down