Thanks for your reply.
I do use pytorch dataloader like below:
class MyTrainImageFolder(torch.utils.data.Dataset):  # Class inheritance
    def __init__(self, root, file_dir, label_dir, transform=MYTFS):
        imgs = []
        labels = []
        img_list = np.load(file_dir)
        labels_list = np.load(label_dir)

        self.imgs = img_list
        self.labels = labels_list
        self.root = root
        self.transform = transform
        self.lens = len(img_list)
        print('total img number:', len(self.imgs))

    def __getitem__(self, index):
        label = torch.tensor(int(self.labels[index]))
        img = Image.open(os.path.join(self.root, self.imgs[index]))
        img = self.transform(img)

        return img, label

    def __len__(self):
        return len(self.imgs)

The problem is, the file in “file_dir” is about 30G, I have more than 200 million images.  Can i build a dataset once when using distributedDataParallel?