# Data Loading takes very long time with Docker compared to local Pytorch without Docker

**URL:** <https://discuss.pytorch.org/t/data-loading-takes-very-long-time-with-docker-compared-to-local-pytorch-without-docker/151562>\
**Category:** data\
**Created:** [May 13, 2022, 4:04am UTC](https://discuss.pytorch.org/t/data-loading-takes-very-long-time-with-docker-compared-to-local-pytorch-without-docker/151562 "2022-05-13T04:04:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hussein\_A\_Hassan](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/hussein_a_hassan/32/44774_2.png) [@Hussein\_A\_Hassan](https://discuss.pytorch.org/u/Hussein_A_Hassan)\
**Post date:** [May 13, 2022, 4:04am UTC](https://discuss.pytorch.org/t/data-loading-takes-very-long-time-with-docker-compared-to-local-pytorch-without-docker/151562/1 "2022-05-13T04:04:30Z")

</div>

Hello

I have a training script when I run it on my local machine, the loading time of the data for one epoch is around 30 minutes but when I run the same script on much powerful server with Docker the loading time takes around 5 hours.

I don’t have much experience with Docker. I used the following Dockerfile to build the image.

FROM [nvcr.io/nvidia/pytorch:21.08-py3](http://nvcr.io/nvidia/pytorch:21.08-py3)

ENV DEBIAN\_FRONTEND=noninteractive  
RUN apt-get update && apt-get install -y ffmpeg  
RUN pip install pandas  
RUN pip install scikit-video  
RUN pip install ffmpeg-python  
RUN pip install scikit-learn  
RUN pip install opencv-python  
RUN pip install tqdm  
RUN pip install torchsummary  
RUN pip install tensorboardX  
CMD [“python”, “./train\_classifier.py”]

and I run the Docker container with the following command:

sudo docker run --ipc=host -it --rm --gpus=device=0 --name train\_container --network=host -v /home/h/data/:/workspace train\_image:3.0 bash

I checked the shared memory of the server and it has over 50% free space during training.  
In addition, when I set the number of workers in the training script to 0 no noticeable difference in the loading time would be achieved.

Please, if you have any suggestion to solve the problem let me know.

Your help is much appreciated.

---

<div class="post-metadata">

**Author:** ![Michal\_Bogacz](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/michal_bogacz/32/35190_2.png) [@Michal\_Bogacz](https://discuss.pytorch.org/u/Michal_Bogacz)\
**Post date:** [May 13, 2022, 5:54am UTC](https://discuss.pytorch.org/t/data-loading-takes-very-long-time-with-docker-compared-to-local-pytorch-without-docker/151562/2 "2022-05-13T05:54:33Z")

</div>

Hello,  
Are those 5h together with container build, or the script execution have just slowed down so much. Good practice is to define the versions of every package, build process would be much faster.  
If the slow-down is only the code slowdown, can you show what happens in code, how do you load data?

---

<div class="post-metadata">

**Author:** ![Hussein\_A\_Hassan](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/hussein_a_hassan/32/44774_2.png) [@Hussein\_A\_Hassan](https://discuss.pytorch.org/u/Hussein_A_Hassan)\
**Post date:** [May 13, 2022, 9:14am UTC](https://discuss.pytorch.org/t/data-loading-takes-very-long-time-with-docker-compared-to-local-pytorch-without-docker/151562/3 "2022-05-13T09:14:46Z")

</div>

Thanks @Michal_Bogacz for your help.

The script execution is just went extremely slow, The 5h is the time to load the data and do some augmentations on it only NOT the container image build.

I am trying to re run the training of the following paper:

> **[TCLR: Temporal Contrastive Learning for Video Representation](https://arxiv.org/abs/2101.07974)**
>
> Contrastive learning has nearly closed the gap between supervised and
> self-supervised learning of image representations, and has also been explored
> for videos. However, prior work on contrastive learning for video data has not
> explored the effect of...

This is the data loader code from the paper:

> <https://github.com/DAVEISHAN/TCLR/blob/main/tclr_pretraining/dl_tclr.py>

I suspect that it could be a limitation on reading speed from the SSD or maybe the  
cpu speed. I don’t know exactly but it could that there are some restrictions made by  
the Docker.

Many Thanks 🙂

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [May 18, 2022, 5:27am UTC](https://discuss.pytorch.org/t/data-loading-takes-very-long-time-with-docker-compared-to-local-pytorch-without-docker/151562/4 "2022-05-18T05:27:55Z")

</div>

> [@Hussein\_A\_Hassan](#):
>
> I don’t know exactly but it could that there are some restrictions made by  
> the Docker.

Did you test the data loading on the server without using docker as it seems you think this issue is docker-related?
