When i use DataLoader, I encountered the problem described as title.
My code is as follows:
    def __getitem__(self, index):
        record = self.video_list[index]
        if self.is_train:
            data = self.feature_list[index]
        else:
            data = self.feature_list[record.id]
        
        print('sample the video size is {}'.format(data.size()))
        # Here is the error
        video_feature = data.mean(dim=0, keepdim=True).view(-1)
        return video_feature

The self.feature_list is the list of tensor saving my train data.
And there is the error information:
sample the video size is torch.Size([10, 2048])
    train(model, train_loader, criterion, optimizer, ep)
  File "train_c3d.py", line 110, in train
    for i, (input, target) in enumerate(train_loader):
  File "/media/data/kmy/envs/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 336, in __next__
    return self._process_next_batch(batch)
  File "/media/data/kmy/envs/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
  File "/media/data/kmy/envs/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/media/data/kmy/envs/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 106, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/media/data/kmy/MBA/fea_dataset.py", line 54, in __getitem__
    video_feature = data.mean(dim=0, keepdim=True).view(-1)
RuntimeError: CUDA error (3): initialization error


Anyone have any idea? Thanks a lot!