libffcv / ffcv

FFCV: Fast Forward Computer Vision (and other ML workloads!)
https://ffcv.io
Apache License 2.0
2.81k stars 180 forks source link

impossible to make a single example dataloader #186

Closed lengstrom closed 2 years ago

lengstrom commented 2 years ago

I get this error when I try to make a dataloader with only a single index: (i.e. any dataloader with indices=[0])

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/mnt/nfs/home/engstrom/conda_envs/ffcvrgb/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/mnt/nfs/home/engstrom/conda_envs/ffcvrgb/lib/python3.9/site-packages/ffcv/loader/epoch_iterator.py", line 79, in run
    result = self.run_pipeline(b_ix, ixes, slot, events[slot])
  File "/mnt/nfs/home/engstrom/conda_envs/ffcvrgb/lib/python3.9/site-packages/ffcv/loader/epoch_iterator.py", line 141, in run_pipeline
    return tuple(x[:len(batch_indices)] for x in args)
  File "/mnt/nfs/home/engstrom/conda_envs/ffcvrgb/lib/python3.9/site-packages/ffcv/loader/epoch_iterator.py", line 141, in <genexpr>
    return tuple(x[:len(batch_indices)] for x in args)
IndexError: dimension specified as 0 but tensor has no dimensions
lengstrom commented 2 years ago

Batch size 1 in general does not work I think either

kristian-georgiev commented 2 years ago

happens for any batch size below 4

numpee commented 2 years ago

I believe this is caused by the Squeeze() Operator in the pipeline (for labels). IIRC, changing to Squeeze(0) resolves the issue.

GuillaumeLeclerc commented 2 years ago

Yes @numpee is right :)