-
Notifications
You must be signed in to change notification settings - Fork 12
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
Tiffslide errors when used in pytorch dataloader with num_workers>1
#18
Comments
Thanks for the report @lukasii ! I created a new issue, because now it's multiprocessing related. Please try moving the slide instantiation to a method that you call from Cheers, |
Thanks Andreas, that did the trick! Would you know why openslide does not need this kind of special treatment? For the record, in the dataset class I added: def worker_init(self, *args):
self.slide = tiffslide.TiffSlide(self.wsi_file) and then creating dataloader as: dataloader = torch.utils.data.DataLoader(
dataset, batch_size=32, shuffle=False, num_workers=4, pin_memory=True,
worker_init_fn=dataset.worker_init
) |
Hi @lukasii Great! I'm happy that it works for you now. ❤️ I'd have to investigate why exactly it doesn't work in the example you provided, but it could be that it's due to pytorch using I'll keep this issue open, until I've worked out the specific details, and either make it work, or crash with a verbose error message suggesting the fix above. Have a great day, and happy training 🎉 |
Thanks for explaining. In case more work on this issue is planned in the future I am attaching updates files. One is my original bug report file, which was incorrectly using a global variable ("self" was missing). Not a big deal as Cheers! |
Unfortunately, tiffslide fails again in parallel mode, this time using pytorch dataloaders. This is a very common technique used in WSI processing with pytorch, the only difference is that it uses process based parallelisation (rather than threads, as in the original bug report).
The symptoms are exactly the same:
num_workers=1
) everything works finenum_workers=4
) the processing failsnum_workers
valueTested using tiffslide version 1.0.0 and tifffile version 2022.2.9. Please see the attached minimalist example.
tiffslide-bug2.zip
Originally posted by @lukasii in #14 (comment)
The text was updated successfully, but these errors were encountered: