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

Error using 4x GPU #9

Open
robmarkcole opened this issue Jan 8, 2024 · 2 comments
Open

Error using 4x GPU #9

robmarkcole opened this issue Jan 8, 2024 · 2 comments

Comments

@robmarkcole
Copy link

Setting gpu_devices=[0, 1, 2, 3] and calling compiled_model.fit I receive:

RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu

Debugging

@samKhallaghi
Copy link
Member

Hi Robin,
It seems that you have fixed the issue regarding training with multiple GPUs. However, please notice that the current implementation uses 'dataparallel' to wrap the model. The problem is when you use multiple GPUs you need to sync the running average of BN layer from each of those GPUs and the current implementation does not have a mechanism to handle it. For the moment it would be safer to only use a single GPU.
One solution is to implement synchronized Batch Normalization that works with dataparallel. A more optimized choice is to use 'DistributedDataParallel' to wrap your model which is more advanced but also more complex to implement as we require to use 'DistributedSampler' to make sure each GPU sees a unique subset of the dataset and requires careful setting of the rank and world_size.
We plan to include the capability soon in the next version of the repo but for now please be cautious of possible performance degradation while using multiple GPUs.

@robmarkcole
Copy link
Author

For context, I typically use pytorch-lightning to handle the training loop, which handles the low level details on synchronisation. For the time being, I am making do with single GPU with this implementation

SethDocherty added a commit to easierdata/multi-temporal-crop-classification-baseline that referenced this issue Dec 18, 2024
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