Skip to content
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

pytorch lightning self.device has incorrect type #701

Closed
ismael-mendoza opened this issue Nov 29, 2022 · 1 comment
Closed

pytorch lightning self.device has incorrect type #701

ismael-mendoza opened this issue Nov 29, 2022 · 1 comment

Comments

@ismael-mendoza
Copy link
Collaborator

ismael-mendoza commented Nov 29, 2022

For now a fixed this with #typing: ignore but curious to know if there is a better solution

I do think however that using self.device is a bit strange (since pytorch lightning automatically moves tensors to GPU) and perhaps should be avoided in cases where it's possible.

@dereklhansen
Copy link
Contributor

dereklhansen commented Dec 2, 2022

If it's just a typing problem, it's okay to ignore since the typing ecosystem isn't perfect yet in Python. Is there a specific location where this is happening and it's an issue?

As far as I am aware, PyTorch lightning only makes sure that tensors from the DataLoader and the LightningModule are on the same device during training. Thus, we still need to get the device for any new tensors being created during calculations. That said, relying on the device attribute of the LightningModule or LightningDataset is often not necessary, because we can often figure out the device from other tensors in scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants