Docker for Deep Learning

I used to go with virtualenv for creating environments for deep learning. But now, there is a problem.

Pop!_OS comes with Python 3.9 whereas Pytorch does not fully support 3.9. I could have gone with pyenv, but I preferred docker. Note that using docker does not affect the performance of Deep Learning notebooks as concluded in Performance Evaluation of Deep Learning Tools in Docker Containers

The following code segment will fetch the image from docker hub and start it. We also mount the folder on our host containing the jupyter notebooks.

Host

docker pull ubuntu:21.10
docker run -it -p 8888:8888 -v /mnt/data/code:/mnt/code --name deep ubuntu:21.10

Inside Running Container

apt-get update && apt-get install python3 python3-pip
pip install pip *** --upgrade --no-cache-dir # where ** means all packages including jupyter
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.token='' --notebook-dir /mnt/codes/

You will be able to access Jupyter notebooks on your host at http://localhost:8888/tree?. You may exit the container.

Note the id of the container via docker ps -a

Then, for subsequent runs, execute the following

docker start -i CONTAINER_ID

Author | MMG

Learning...