-
Hi there, I'm wondering if I can get some assistance. I'm training a unet with paired images that have been randomly cropped to 32x32x32 from larger images that I stored on ram using cachedataset. I then use a PatchDataset implementing randcropbyposneglabeld and then CacheDataset to make training faster. However, the patch loading appears to be a major bottleneck with around 42000 patches (1000 patches for 42 images) taking around 15 hours to load. When I try to increase the number of workers from 1, the image pairs appear unaligned after plotting and I get this error in training:
From the discussions I've read in the issues, I believe it is due to the randcropbyposneglabel transform and other random transforms I have added not yet being implemented as thread safe. I'm wondering if anyone has found a way around this problem to speed up caching rate. Is using PyTorch's thread safe random transforms and implementing them to be applied on both the image and label the only current solution? Here is my code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Hi @fogunsan, from the error message, I think the error is due to your different sizes when stack them into a batch. Maybe you can try to add |
Beta Was this translation helpful? Give feedback.
Hi @fogunsan, I just get your points, I don't think we can pass a dataset to
CacheDataset
sinceCacheDataset
can only cache non-random transforms. And also most of the random transforms are non-thread safe.MONAI/monai/data/dataset.py
Lines 735 to 740 in 98b6a15