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

RuntimeError: The size of tensor a (2) must match the size of tensor b (4) at non-singleton dimension 0 #79

Open
MarkoHaralovic opened this issue Sep 20, 2024 · 0 comments

Comments

@MarkoHaralovic
Copy link

Issue: RuntimeError during Pretraining on ImageNet with Small Batch Sizes

I encountered the following error when trying to pretrain any of the models on ImageNet:

RuntimeError: The size of tensor a (2) must match the size of tensor b (4) at non-singleton dimension 0

Environment

  • Setup: Single GPU environment

Issue

The issue seems to stem from the batch size configuration, specifically when the batch size is lower than 16. The model fails with the mentioned error when trying to run with small batch sizes.

Workaround

The error can be avoided by setting the batch size to any multiple of 2 that is greater than or equal to 16.

Suggested fix

It would be helpful to handle this error more gracefully or provide clear documentation that the batch size needs to be a multiple of 2 and at least 16 when using certain configurations.

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

1 participant