question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto dataloader - ValueError: batch_size should be a positive integer value, but got batch_size=0

See original GitHub issue

🐛 Bug description

The following code will brake if batch_size is smaller than world size :

import torch
import ignite.distributed as idist

def foo(i):
    data = torch.arange(100).reshape(25, 4)
    data_loader = idist.auto_dataloader(data, batch_size=6, num_workers=12)


if __name__ == "__main__":
    idist.spawn("gloo", foo, args=(), nproc_per_node=8)    
ValueError: batch_size should be a positive integer value, but got batch_size=0

A fix can be:

  • keep batch size as provided if smaller than world size
  • same for num_workers

Environment

  • PyTorch Version (e.g., 1.4): 1.5.0
  • Ignite Version (e.g., 0.3.0): master
  • OS (e.g., Linux): linux
  • How you installed Ignite (conda, pip, source):
  • Python version: 3.7
  • Any other relevant information:

@InCogNiTo124 would you like to fix this as you recently played around auto_* ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
InCogNiTo124commented, Jun 15, 2020

@vfdev-5 alright, I’ll let you know if I can’t fix it by then 😃

0reactions
vfdev-5commented, Jun 17, 2020

@InCogNiTo124 yes, you are correct about that: 6 // 8 = 0

A fix cant be:

@vfdev-5 I’m not sure if this is a typo or not

And yes, it is a typo. I fixed it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: batch_size should be a positive integer value
Any idea what is causing this error message. “ValueError: batch_size should be a positive integer value, but got batch_size=Compose(
Read more >
ValueError: num_samples should be a positive integer ...
I have the error of the title ValueError: num_samples should be a positive integer value, but got num_samples=0 because basically I am ...
Read more >
PyTorch Dataloader Overview (batch_size, shuffle ...
Automatic data shuffling. In this tutorial, you will review several common examples of how to use Dataloaders and explore settings including dataset, batch_size...
Read more >
Source code for pytorch_forecasting.data.timeseries
Timeseries datasets. Timeseries data is special and has to be processed and fed to algorithms in a special way. This module defines a...
Read more >
tf.data.Dataset | TensorFlow v2.11.0
Once you have a dataset, you can apply transformations to prepare the data for ... if batch_size does not divide the number of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found