Pytorch使用DistributedDataParallel单机多卡训练时遇到ValueError: sampler option is mutually exclusive with shuff

Pytorch使用DistributedDataParallel单机多卡训练时遇到
ValueError: sampler option is mutually exclusive with shuffle的报错

是因为sampler选项与shuffle互斥
在数据读取这一块,需要将shuffle改成 False

train_dataset = datasets.ImageFolder(root='data/train/', transform=data_transform)
train_sampler = torch.utils.data.distributed.DistributedSampler(train_dataset)

train_loader = torch.utils.data.DataLoader(train_dataset,
                                           batch_size=batch_size,
                                           shuffle=False, # 得改成False
                                           num_workers=num_workers,
                                            sampler=train_sampler
                                           )

你可能感兴趣的:(报错记录,深度框架,Pytorch)