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

map device management #15

Open
ethanwharris opened this issue Feb 23, 2024 · 2 comments
Open

map device management #15

ethanwharris opened this issue Feb 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@ethanwharris
Copy link
Member

🚀 Feature

Provide an easy or automated way to get batches + models on to the correct device with map.

Motivation

We often want to map over a bunch of GPU machines, maybe each with more that one GPU on board. Right now, deciding which device to use in each process is a little tricky, you have to get the rank modulo the number of CUDA devices.

Pitch

Probably the cleanest thing would be to just automatically handle devices more like a LightningModule - maybe if you pass an nn.Module to map we could put it on a correct device for the process and wrangle the inputs / outputs.

Alternatives

Additional context

@ethanwharris ethanwharris added enhancement New feature or request help wanted Extra attention is needed labels Feb 23, 2024
@tchaton
Copy link
Collaborator

tchaton commented Feb 23, 2024

Hey @ethanwharris,

The map and optimize callable supports some sort of device already. You just need to add the optional device argument to your callable.

def fn(..., device):
    ...

map(fn, ...)

Does this solve your issue ?

@ethanwharris
Copy link
Member Author

@tchaton

Cool, yeah so we can probably mark this as done - although hard to discover that you can do it, might still be nice to just pass an nn.Module or something and have it done automatically 😃

@Borda Borda removed the help wanted Extra attention is needed label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants