Multi-GPU "[LightningModule] object has no attribute [attribute]" #3100
Replies: 5 comments
-
https://pytorch-lightning.readthedocs.io/en/latest/lightning-module.html#prepare-data |
Beta Was this translation helpful? Give feedback.
-
Thank you @rohitgr7 ! What if I want to save an attribute between method calls? I have |
Beta Was this translation helpful? Give feedback.
-
I believe it should work since except |
Beta Was this translation helpful? Give feedback.
-
Okay, I'll try it and report back, thanks! I see the docs also mention important methods to call for DP/DDP2 to aggregate data at the end of steps. I'll try that as well. |
Beta Was this translation helpful? Give feedback.
-
I got it. The attribute error was no attribute named |
Beta Was this translation helpful? Give feedback.
-
What is your question?
When trying to use multiple GPUs with either "DP" or "DDP", I get errors
"[Module] object has no attribute [the attribute]"
. I'm storing data in between methods withself
. For example, because I want to visualize validation images, I storeself.batch = batch
invalidation_step()
so I can visualize it duringvalidation_epoch_end()
. But I get the error"Module] object has no attribute 'batch'
. This happens for otherself
attributes too, e.g. withself.val_dataset
I create inprepare_data()
.The error only occurs when trying to use multiGPU. I suspect it could be a thread synchronization issue, but I don't know how to resolve it. Would anyone have any idea, please?
Code
Snipped Code Example
And the error is below. Just the text in red is relevant:
What have you tried?
Tried DP and DDP. Tried reading lightning docs and google, but couldn't find anything related to Lightning. Not sure if it's related to needing ".module" on DataParallel-wrapped modules, but it seems strange that Lightning would require that.
What's your environment?
Beta Was this translation helpful? Give feedback.
All reactions