AttributeError in DataLoader using Opacus

Hello,
I was excited to learn about Opacus so now I’m trying to apply it to my training. I’m using DataLoader with my custom dataset MyDataset(Dataset). During calling dataloader to get data I’m getting an error:
File “***\lib\multiprocessing\reduction.py”, line 60, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can’t pickle local object ‘wrap_collate_with_empty..collate’

Do anyone of you can help me with fixing it? I can provide more insight, but don’t know where to start.
Win10
Pytorch 1.13
Opacus 1.1.3
(training worked before applying opacus)

Thanks for raising this issue. Would you be able to share a minimal reproducing example? I also see that you use Opacus 1.1.3, can you update to the latest version (1.3)?

Hi Alexandre,
thank you for your reply. I’ve updated opacus to 1.3, however somehow conda does not provide lastest opacus release - I had to do that via pip.

Nonetheless, the problem persisted. I thought that maybe it’s the multiprocessing/trainloader problem so I’ve set the number of workers to 0, and it helped to workaround the problem.

I will still try to post a minimal working example this week, so maybe we will figure out a solution rather than workaround.

(So now it is:
Win10
Pytorch 1.13
Opacus 1.3)

Thanks! We are very interested in knowing if it is a general problem with multiprocessing.