pytorch-semantic-segmentation icon indicating copy to clipboard operation
pytorch-semantic-segmentation copied to clipboard

Inconsistent Tensor Sizes Error when using batch size > 1 for Pascal VOC

Open rohitgajawada opened this issue 7 years ago • 4 comments

Hi! When I tried running your train code for pascal voc, I get RuntimeError: inconsistent tensor sizes at /pytorch/torch/lib/TH/generic/THTensorMath.c:2709 I'm not able to find out the reason for the error Thank you

rohitgajawada avatar Jan 06 '18 07:01 rohitgajawada

Traceback (most recent call last): File "train.py", line 252, in main() File "train.py", line 105, in main train(train_loader, net, criterion, optimizer, curr_epoch, args, val_loader, visualize) File "train.py", line 113, in train for i, data in enumerate(train_loader): File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 187, in next return self._process_next_batch(batch) File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 221, in _process_next_batch raise batch.exc_type(batch.exc_msg) RuntimeError: Traceback (most recent call last): File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 40, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 109, in default_collate return [default_collate(samples) for samples in transposed] File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 91, in default_collate return torch.stack(batch, 0, out=out) File "/home/rohit.gajawada/.local/lib/python2.7/site-packages/torch/functional.py", line 66, in stack return torch.cat(inputs, dim, out=out) RuntimeError: inconsistent tensor sizes at /pytorch/torch/lib/TH/generic/THTensorMath.c:2709

rohitgajawada avatar Jan 06 '18 07:01 rohitgajawada

@rohitgajawada make sure your pytorch version == 0.2.0

zhijiew avatar Jan 10 '18 13:01 zhijiew

This also happened to me. My pytorch version is 0.3.0 on Windows 10. How to fix this problem?

wuyi1983 avatar Feb 08 '18 18:02 wuyi1983

According to requirements.txt, use pytorch 0.2.

2018-02-09 2:29 GMT+08:00 wuyi1983 [email protected]:

This also happened to me. My pytorch version is 0.3.0 on Windows 10. How to fix this problem?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ZijunDeng/pytorch-semantic-segmentation/issues/28#issuecomment-364204999, or mute the thread https://github.com/notifications/unsubscribe-auth/AOMWC7aXq0nK7glyavIL_HIfdV55or1Fks5tSz0RgaJpZM4RVOPn .

ksnzh avatar Feb 10 '18 09:02 ksnzh