Deep Learning Frameworks

TensorFlow Docker

Containers help improve security, reproducibility, and scalability in software development, data science, and deep learning. Using containers is an excellent way to create easy-to-deploy, repeatable environments for your deep learning projects. With Docker containers as the development environment, you don’t need to install and set up the environment for the various frameworks. Experiments are guaranteed to run everywhere and will run the same every time.

What is Docker and How is it Used with TensorFlow?

Docker is a platform used to develop, deploy, and run applications by using the benefits of containerization. It ensures that all applications remain isolated in a container and packaged with all their dependencies and libraries.


Docker containers are used to create virtual environments, which can run TensorFlow. Within these environments, TensorFlow can, for example, share resources with its host machine, access directories, use a GPU, and connect to the internet, while remaining separate from the rest of the system.


Advantages of Using a Docker Image to set up TensorFlow

  • Dependencies and requirements are satisfied for all the different frameworks
  • Getting the right Anaconda distribution and the correct version of Python
  • Setting up the paths and the correct versions of different packages
  • Ensuring the installation does not interfere with other Python-based installations.


You can also test each release of the TensorFlow Docker images in these virtual environments. Using Docker also makes sharing projects with others a painless process. You don’t have to worry about environments not being compatible, missing dependencies or even platform conflicts.


Using Docker for Deep Learning in Research Environments

Many modern deep learning researchers rely on more than one framework. Running several deep learning frameworks or multiple versions of a framework on a single machine can be challenging.

Docker provides ready-to-go containers for each framework, which gives you the flexibility to experiment, without the risk of damaging your current environment. With Docker, the frameworks are entirely self-contained. If something is not working correctly, simply remove the entire container and start over, by performing a “docker run” command.


If you are only using one framework, like TensorFlow, in an experiment, it is probably already containerized. This means you can simply execute TensorFlow using the “docker run” command and it will not compromise your local workstation. You can simply download it, test it, and use it, and if the experiment doesn’t fit your needs, discard the container and move on


Using Docker for Deep Learning in Development Environments

As with any development project, it is important to make experiments and results reproducible. For deep learning, you should implement practices that effectively track code and ensure the training of data, weights, statistics, and files. You should also ensure this code and data can be rerun and reused with subsequent experiments. When you use containerized environments within Docker and images from Docker hub, you can achieve reproducible results in your deep learning experiments.


Containerized environments and images can be advantageous when you deploy deep learning at large organizations. You can also effectively use containerized environments for distributed development environments where deep learning talent is spread across different organizations, departments, or geographical regions. Also, you can manage and customize your deployment further by using orchestration tools like Kubernetes or Docker Swarm.


Supercharging Experiment Management and Reproduction with MissingLink

MissingLink abstracts away the complexity of managing Docker or Kubernetes, letting you manage and run experiments on multiple machines from a simple dashboard and CLI.


missinglink screenshot

Quick Tutorial: Real-Time TensorFlow Object Recognition with, Docker, and a GPU

The following tutorial steps are summarized. See the full tutorial by Reda Boumahdi.


In this tutorial, we package all the necessary tools needed for object recognition. The goal is to be able to run any computer vision algorithm on any machine within minutes.


1. Install Docker


> curl -fsSL | sudo apt-key add -
> sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
> sudo apt-get update
> apt-cache policy docker-ce
> sudo apt-get install -y docker-ce
> sudo systemctl status docker


2. Install nvidia-docker to leverage NVIDIA GPUs


> wget
> sudo dpkg -i nvidia-docker*.deb


2.1 Test your Installation


> sudo nvidia-docker run --rm nvidia/cuda nvidia-smi


3. Run a Jupyter Notebook with TensorFlow powered by GPU and OpenCv


> sudo nvidia-docker run --rm --name tf1 -p 8888:8888 -p 6006:6006 redaboumahdi/image_processing:gpu jupyter notebook --allow-root


Then you will need to navigate to your localhost and use the port 8888 and paste your token to identify and access your Jupyter notebooks.


4. Real-Time Object Recognition


The following code tracks objects over frames with a webcam. It is a sample of code taken from the following GitHub repository.


First of all, we need to open access to the xserver to our docker image. There are different ways of doing so. We will open access to xserver to anyone.


> xhost +local:root


Then we will bash to our Docker image using this command:


> sudo docker run -p 8888:8888 --device /dev/video0 --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" -it image_processing bash


We will need to clone the github repository, which is a real-time object detector:


> git clone && cd object_detector_app/


Finally, you can launch the python code:


> python


Scaling Up TensorFlow Docker Deployments


running experiment across multiple machines

Resource management

Deploying TensorFlow Docker images works well at a small scale but as you grow in the number of machines you need to orchestrate containers using Kubernetes and it can get very complex.


MissingLink takes away all the complexity of Docker and Kubernetes by managing resources run experiments.

tracking experiments

Experiment management

The visibility into what is running in each container is limited, you don’t have a central view of all the parameters and metrics.


MissingLink gives you full visibility into running experiments which you can’t get with Docker or Kubernetes.

manage training datasets

Data management

Containers are immutable, you can’t put experiment data in a Docker container.

MissingLink packages data into experiments dynamically with a simple CLI command.

Start using Missinlink’s platform to take away the complexity of Docker and Kubernetes by managing resources and run experiments seamlessly. Learn more to see how easy it is.

Learn More About Deep Learning Frameworks