kbressem / faimed3d

Extension to fastai for volumetric medical data
MIT License
32 stars 14 forks source link

Multiprocessing fails for ImageDataLoaders with multiple inputs #27

Closed kbressem closed 3 years ago

kbressem commented 3 years ago

Describe the bug When using multiple inputs in a CNN, the Learner gets stuck at the start.

To Reproduce Steps to reproduce the behavior:

d = pd.read_csv('../data/radiopaedia_cases.csv')
dls = ImageDataLoaders3D.from_df(d,
                                 fn_col = [0,1],
                                size_for_resampling = (112, 112, 20),
                                 label_col = 2, # in sample data 0: series, 1: segmentation mask, 2: random binary label
                                 bs = 2, 
                                 val_bs = 2
                                 )

learn = cnn_learner_3d(dls, r3d_18, pretrained=False)

learn.fine_tune(1, 0.001)

Screenshots Traceback shows that the model gets stuck at the dataloader,

image

Workaround until issue is fixed is to set num_workers=0, but this makes the training longer.

kbressem commented 3 years ago

Setting sitk.ProcessObject_SetGlobalDefaultNumberOfThreads(1) solves the issue. It is now automatically set when loading data.