Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion monai/transforms/spatial/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def __init__(
self,
axcodes: Optional[str] = None,
as_closest_canonical: bool = False,
labels: Optional[Sequence[Tuple[str, str]]] = tuple(zip("LPI", "RAS")),
labels: Optional[Sequence[Tuple[str, str]]] = (("L", "R"), ("P", "A"), ("I", "S")),
image_only: bool = False,
) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/spatial/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def __init__(
keys: KeysCollection,
axcodes: Optional[str] = None,
as_closest_canonical: bool = False,
labels: Optional[Sequence[Tuple[str, str]]] = tuple(zip("LPI", "RAS")),
labels: Optional[Sequence[Tuple[str, str]]] = (("L", "R"), ("P", "A"), ("I", "S")),
meta_keys: Optional[KeysCollection] = None,
meta_key_postfix: str = DEFAULT_POST_FIX,
allow_missing_keys: bool = False,
Expand Down
7 changes: 4 additions & 3 deletions monai/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
_seed = None
_flag_deterministic = torch.backends.cudnn.deterministic
_flag_cudnn_benchmark = torch.backends.cudnn.benchmark
MAX_SEED = np.iinfo(np.uint32).max + 1 # 2**32, the actual seed should be in [0, MAX_SEED - 1] for uint32
NP_MAX = np.iinfo(np.uint32).max
MAX_SEED = NP_MAX + 1 # 2**32, the actual seed should be in [0, MAX_SEED - 1] for uint32


def zip_with(op, *vals, mapfunc=map):
Expand Down Expand Up @@ -225,7 +226,7 @@ def get_seed() -> Optional[int]:


def set_determinism(
seed: Optional[int] = np.iinfo(np.uint32).max,
seed: Optional[int] = NP_MAX,
use_deterministic_algorithms: Optional[bool] = None,
additional_settings: Optional[Union[Sequence[Callable[[int], Any]], Callable[[int], Any]]] = None,
) -> None:
Expand All @@ -250,7 +251,7 @@ def set_determinism(
"""
if seed is None:
# cast to 32 bit seed for CUDA
seed_ = torch.default_generator.seed() % (np.iinfo(np.int32).max + 1)
seed_ = torch.default_generator.seed() % MAX_SEED
torch.manual_seed(seed_)
else:
seed = int(seed) % MAX_SEED
Expand Down
4 changes: 3 additions & 1 deletion tests/test_integration_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
from tests.utils import DistTestCase, SkipIfBeforePyTorchVersion, TimedCall, skip_if_no_cuda, skip_if_quick


def run_loading_test(num_workers=50, device="cuda:0" if torch.cuda.is_available() else "cpu", pw=False):
def run_loading_test(num_workers=50, device=None, pw=False):
"""multi workers stress tests"""
set_determinism(seed=0)
if device is None:
device = "cuda:0" if torch.cuda.is_available() else "cpu"
train_ds = list(range(10000))
train_loader = DataLoader(train_ds, batch_size=300, shuffle=True, num_workers=num_workers, persistent_workers=pw)
answer = []
Expand Down