Environment information
fastai version: 1.0.38
PyTorch version: 1.0.0
Is debug build: No
CUDA used to build PyTorch: 9.0.176
OS: Ubuntu 16.04.5 LTS
GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
CMake version: version 3.12.2
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: Quadro M4000
Nvidia driver version: 410.48
cuDNN version: Could not collect
Versions of relevant libraries:
[pip] Could not collect
[conda] pytorch 1.0.0 py3.6_cuda9.0.176_cudnn7.4.1_1 pytorch
[conda] pytorch-nightly 1.0.0.dev20181115 py3.6_cuda9.0.176_cudnn7.1.2_0 pytorch
[conda] torchvision 0.2.1 py_2 pytorch
[conda] torchvision-nightly 0.2.1 py_0 fastai
Error
RuntimeError: Traceback (most recent call last):
File "/home/paperspace/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/paperspace/anaconda3/lib/python3.6/site-packages/fastai/torch_core.py", line 105, in data_collate
return torch.utils.data.dataloader.default_collate(to_data(batch))
File "/home/paperspace/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 232, in default_collate
return [default_collate(samples) for samples in transposed]
File "/home/paperspace/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 232, in <listcomp>
return [default_collate(samples) for samples in transposed]
File "/home/paperspace/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 209, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 3146 and 3009 in dimension 2 at /opt/conda/conda-bld/pytorch_1544174967633/work/aten/src/TH/generic/THTensorMoreMath.cpp:1333
Reproduce
tfms = get_transforms()
data = ImageDataBunch.from_csv(
path=DATA_PATH,
folder='train',
csv_labels=LABELS_PATH,
sep=',',
bs=bs,
ds_tfms=tfms,
num_workers=1,
).normalize(imagenet_stats)
print(len(data.train_ds))
Output: 1882
I get this warning:
/home/paperspace/anaconda3/lib/python3.6/site-packages/fastai/basic_data.py:211: UserWarning: It's not possible to collate samples of your dataset together in a batch.
Shapes of the inputs/targets:
[[torch.Size([3, 2106, 1433]), torch.Size([3, 3240, 1917]), torch.Size([3, 2751, 1713]), torch.Size([3, 1556, 1188]), torch.Size([3, 2984, 1811]), torch.Size([3, 2705, 1693]), torch.Size([3, 2905, 1778]), torch.Size([3, 2977, 1808]), torch.Size([3, 3533, 2036]), torch.Size([3, 3652, 2084]), torch.Size([3, 3103, 1860]), torch.Size([3, 3063, 1843]),
lr = 1e-2
learn = create_cnn(
data=data,
arch=models.resnet34,
pretrained=True,
metrics=[metrics.error_rate, metrics.accuracy]
)
learn.fit_one_cycle(1, lr)
My hunch is that there’s something wrong how I am using the ImageDataBunch since I can successfully get the course3 notebook lesson1-pets working.