PicklingError: Can’t pickle : attribute lookup on main faied
- 报错显示
- 任务背景
- 解决方案
报错显示
PicklingError: Can’t pickle <function at 0x000001EA6923EAF0>: attribute lookup on main failed |
---|
任务背景
使用pytorch中的 DataLoader 生成数据集(cifar2数据集)的时候,想查看图像数据的维度,这时候打印出错
程序:
## num_workers (int, optional): how many subprocesses to use for data loading.
dl_train = DataLoader(ds_train, batch_size = 50, shuffle = True, num_workers=3)
dl_valid = DataLoader(ds_valid, batch_size = 50, shuffle = True, num_workers=3)# Pytorch的图片默认顺序是 Batch,Channel,Width,Height
for x,y in dl_train:print(x.shape,y.shape) break
解决方案
https://icode9.com/content-4-1117833.html
将 参数 num_workers = 3 修改为 num_workers = 0
然后问题得到解决。