From b241ff522578746afaba955ed43b467a1430ce99 Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Tue, 31 Aug 2021 23:43:13 +0800 Subject: [PATCH] [DLMED] enhance doc-string of ToDevice Signed-off-by: Nic Ma --- monai/transforms/utility/array.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index 918763405f..dd045817fb 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -1075,6 +1075,12 @@ class ToDevice(Transform): Move PyTorch Tensor to the specified device. It can help cache data into GPU and execute following logic on GPU directly. + Note: + If moving data to GPU device in the multi-processing workers of DataLoader, may got below CUDA error: + "RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, + you must use the 'spawn' start method." + So usually suggest to set `num_workers=0` in the `DataLoader` or `ThreadDataLoader`. + """ def __init__(self, device: Union[torch.device, str], **kwargs) -> None: