Are you using a custom sampler or collate_fn?
If the length of the dataset is given as 100, this code should work:
for idx in range(100):
    batch = dataset[idx]

while using a DataLoader only returns a single sample?
loader = DataLoader(dataset, batch_size=1)
for idx, batch in enumerate(loader):
    print(idx)