# Ds.iter\_batches is much slower than from torch.dataloader

**URL:** <https://discuss.ray.io/t/ds-iter-batches-is-much-slower-than-from-torch-dataloader/9768>\
**Category:** Ray Data\
**Created:** [March 15, 2023, 10:15am UTC](https://discuss.ray.io/t/ds-iter-batches-is-much-slower-than-from-torch-dataloader/9768 "2023-03-15T10:15:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanxiaod123](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yanxiaod123/32/4061_2.png) [@yanxiaod123](https://discuss.ray.io/u/yanxiaod123)\
**Post date:** [March 15, 2023, 10:15am UTC](https://discuss.ray.io/t/ds-iter-batches-is-much-slower-than-from-torch-dataloader/9768/1 "2023-03-15T10:15:42Z")

</div>

I have a test, ds.iter\_batches batch szie=32, every fetch time approximately equal to 40ms，i think is much slower。  
arr = np.random.randint(10, size=(1028, 224, 224, 3))  
dataset: Dataset = ray.data.from\_numpy(arr)  
pipe : DatasetPipeline = dataset.window(blocks\_per\_window=1)  
start\_time = time.time()  
for data in pipe.iter\_batches(batch\_size=1, batch\_format=“numpy”):  
print('get data time is ', time.time() - start\_time)  
start\_time = time.time()

---

<div class="post-metadata">

**Author:** ![matthewdeng](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/matthewdeng/32/1446_2.png) [@matthewdeng](https://discuss.ray.io/u/matthewdeng)\
**Post date:** [March 18, 2023, 1:24am UTC](https://discuss.ray.io/t/ds-iter-batches-is-much-slower-than-from-torch-dataloader/9768/2 "2023-03-18T01:24:47Z")

</div>

(For better linking of information, this is also posted on Github [here](https://github.com/ray-project/ray/issues/33325) and being tracked [here](https://github.com/ray-project/ray/issues/31108).)
