thuml / Transfer-Learning-Library

Transfer Learning Library for Domain Adaptation, Task Adaptation, and Domain Generalization
http://transfer.thuml.ai
MIT License
3.39k stars 553 forks source link

Problem when training dann using multiple GPUs #229

Closed NightXBurn closed 4 months ago

NightXBurn commented 1 year ago

Describe the bug When training dann using multiple GPUs with PyTorch lightning lib the following error arises: AttributeError: Can't pickle local object 'DomainAdversarialLoss._ init _.locals>.lambda>' To Reproduce Wrap the dann model inside a lightningModule

Expected behavior Training runs smoothly without problems

Desktop (please complete the following information):

Fix Remove the unused 66 and 67 lines from tllib/alignment/dann.py file. The lines contain a lambda function that cannot be pickled, thus it cannot be shared across multiple processes.

The code is: self.bce = lambda input, target, weight: F.binary_cross_entropy(input, target, weight=weight, reduction=reduction)

thucbx99 commented 4 months ago

Thanks for your advice. We are sorry that we will not update this library recently.