-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] np.pad() consumes a lot of time when the dataset is big? #67
Comments
Did you solved the problem? |
Dear @xuelicheng1992 , @tohsakask , I'm not sure if there is any way to improve the current IO setup: The dataloader uses numpy memory maps to avoid loading the entire scans and only extracts the needed patch. The I wouldn't expect this to be an issue with the dataset size though, is there a difference between the two datasets you used in terms of spatial size (image "resolution" / number of voxels)? Since it is hard to debug the issue without having access to your specific dataset, did you try to reproduce the issue with the toy data? Best, |
Hi @mibaumgartner , |
Hi @tohsakask , |
Hi @mibaumgartner , |
Hi @xuelicheng1992 , thanks for the detailed update, indeed, I didn't think about RAM consumption when reading this issue. Training / Augmentation will definitely slow down significantly when the RAM is full. The RAM usage depends on several parameters of nnDetection: patch size for training (this is independent from the data size in itself, since it only reads the needed patch), number of workers/processes (each worker reads a single batch, so increasing num workers leads to faster augmentation but it increases RAM usage as well), num_cached_per_thread (can be found in the train config; it defined how many results after augmentation will be saved to a queue and decreasing this will save less batches there) and batch size (since each worker reads a batch, increasing the batch size will result in more patches loaded simultaneously). Decreasing num_cacher_per_thread and finding a balance Please don't normalize the data file (float32) to uint8! This will certainly destroy your data - The data is normalized to zero mean and unit standard variance, thus normalization to an integer type is not an option. I tried some experiments with float16 for data and uint8 for seg but didn't test this setting on the full cohort, so I can not guarantee that it won't decrease results. Furthermore, I'm not sure if this will actually reduce RAM consumption since the data is casted to float32 (I think scikit might even cast to float64 internally for the resampling in the SpatialTransform) after loading, it is a good way to reduce IO though. Best, |
Regarding the big and small patch size: The extracted patch size is bigger than the training patch size to avoid border artefacts during the augmentation step. The spatial transform will automatically crop the patch to the final (i.e. the size used to train) patch size. |
Hi @mibaumgartner , |
❓ Question
Hi! great job!:
I've been using nnDetection in my experiments.I found a phenomenon:
1.one epoch costs about 30 minute (2600/2600,patch size [ 96 192 160]) ,when the number of dataset cases is 163 .
2.one epoch costs about 6 hour (2600/2600,patch size [ 96 160 160] ) ,when the number of dataset cases is 534 .
Then I search what went wrong. I found top command:
1.%CPU 0.0wa,when the number of dataset cases is 163 .
2.%CPU 18.0~36.0wa,when the number of dataset cases is 534 .
Then I know something wrong about data IO and debug /XXX/XXX/nndet/io/datamodule/bg_loader.py Function generate_train_batch(). Finally.found /XXX/XXX/nndet/io/patching.py:line 432 np.pad() was the reason.
1.about 20ms each time,when the number of dataset cases is 163 .
1.about 6-8s each time,when the number of dataset cases is 534 .
How can I solve this problem?
The text was updated successfully, but these errors were encountered: