Not sure what your batch size is, but that sounds incredibly slow. Are you using Windows?
If so, Windows has some issues with parallelizing workers, as mentioned here:
  

      github.com/pytorch/pytorch
  

  
    
  
	  
  

  
    
      In windows, DataLoader with num_workers > 0 is extremely slow (50 times slower)
    

    
      
        opened 
        
          
        
        Oct 18, 2018
      
      


      
        
          
          taohu88
        
      
    

    
        
          high priority
        
        
          module: windows
        
        
          module: multiprocessing
        
        
          triaged
        
    
  


  
    ## 🐛 Bug

In windows, DataLoader with num_workers > 0 is extremely slow (pytor…ch=0.41)


## To Reproduce
Step 1: create two loader, one with num_workers and one without.
import torch.utils.data as Data
train_loader = Data.DataLoader(dataset=train_dataset, 
                               batch_size=batch_size, shuffle=True)

train_loader2 = Data.DataLoader(dataset=train_dataset, 
                               batch_size=batch_size, shuffle=True, num_workers=1)
Step 2:  time it
%%time

for _ in range(200):
    for x in train_loader:
        pass

%%time
for _ in range(200):
    for x in train_loader2:
        pass

The first one took only 2.5 s
The second one took 1min 47s
---------------------------------------------------------------------------
Collecting environment information...
PyTorch version: 0.4.1
Is debug build: No
CUDA used to build PyTorch: None

OS: Microsoft Windows 10 Enterprise
GCC version: Could not collect
CMake version: version 3.11.0-rc3

Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
  

  

  
    
    
  

  


If your dataset can fit into cpu memory or another gpu, I suggest putting all your data into memory. With this loader, I went from several seconds a batch to a fraction of a second. Here is an example:
import torch
import numpy as np
from numpy.random import default_rng


class FastLoader():
    def __init__(self, dataset, labels, batch_size, device, testing=False):
        self.length = dataset.size()[0]
        self.dataset = dataset
        self.labels = labels
        self.indexer = np.arange(self.length)
        self.testing = testing
        self.batch_size = batch_size
        self.max_idx = self.length // batch_size + 1
        self.fin_batch_len = self.length - self.length // batch_size

        self.device = device

        if not testing:
            self.shuffler()

    def shuffler(self):
        rng = default_rng()
        rng.shuffle(self.indexer)

    def __len__(self):
        return self.length

    def get_batch(self, idx):
        if idx == self.max_idx:
            mini_idx = self.indexer[idx * self.batch_size:idx * self.batch_size + self.fin_batch_len]
        else:
            mini_idx = self.indexer[idx * self.batch_size:idx * self.batch_size + self.batch_size]

        data = self.dataset[mini_idx, ...]
        labels = self.labels[mini_idx, ...]

        # preprocessing goes here | make sure any tensors made are cast to self.device
        
        return data, labels


# Usage Example
device = torch.device("cpu")
A = torch.rand((10000, 3, 32, 32), device=device)
labels = torch.rand(10000, device=device)
trainloader = FastLoader(A, labels, batch_size=128, device=device)

for idx in range(trainloader.max_idx):
    data, labels = trainloader.get_batch(idx)
    print(data.size(), labels.size())
    
# You can reshuffle the trainloader indices between epochs with:
trainloader.shuffler()

With the above, all you need to feed it is a tensor of the whole dataset. It should have the dims you use in each batch such as (batch_size, channels, dims, dims)
import glob
import pandas as pd


def data2gputens(path, device, data_dim):
    out = torch.empty((0, *data_dim), device=device, requires_grad=False, dtype=torch.float32)
    start_column, stop_column = 1, 6
    for p_idx, fname in enumerate(glob.glob(path + "*.csv")):
        data_file = pd.read_csv(fname, header=None)
        out = torch.cat([out, torch.tensor(data_file.iloc[:, start_column:stop_column].values, device=device,
                                           requires_grad=False, dtype=torch.float32).view(-1, *data_dim)])
    return out

# Usage of data2gputens :
directory = "data/"
device = torch.device("cpu")
data_dim = (95, 5)
train_dataset = data2gputens(directory, device, data_dim)

Of course, you’ll have to adjust the above definition to your data’s size, whether they be images, sequences, etc. and where the data is stored.