One of the main problems of the machine learning part is installing software because we need to research algorithms, frameworks, and software libraries for identifying suitable technology for our application. Installing new software & libraries takes some time. We may also face some issues during the setup process. To overcome these problems we ought for some technique, which is a docker environment.
Why Docker for machine learning???
Docker will take care of the below issues.
Issues 1: Most of the Machine learning application is running with third -party library and software. Here, A developer, while deploying an application to the production server has to maintain a note of the software’s that are installed in the local development machine.
Issues 2: Machine learning world provides a wide range of third party applications which can be consumed by our application. For example, Detection of an object from webcam can be done through Open CV and Open GL software) Here, a developer faces hindrance about the feasibility and speed of the software to our application. Installing more & more software’s to the application would make the machine to be slow or to crash.
Issues 3: Version conflict of languages is another important problem faced by the developers. Example, Running two different projects which is built on python 2 and python 3 respectively on the same machine is not possible.
Issues 4: We need to download and install software manually in our system, but in Docker environment, its just a single command and build the application. Version switching is easier here.
Use case of machine learning with docker
Here, We are going to see Tensorflow object detection with docker.
Now the time to choose an option for machine learning environment.
Option 1: If you want to run tensorflow object detection app in your machine, You need to install below dependencies here.
- Protobuf 3.0.0
- Pillow 1.0
- tf Slim (which is included in the “tensorflow/models/research/” checkout)
- Jupyter notebook
- Tensorflow (>=1.9.0)
Option 2:Install docker on your machine here.
First, Create a docker file in your application path and paste the below command on it.
Run the Docker build command.
Now, the tensorflow environment is ready!!!
If you want to install open CV, Just add this one line on docker file.
RUN apt-get install python-opencv -y
I prefer docker-compose is a good one to go. So below is my docker and docker-compose file for object detection with docker.
FROM tensorflow/tensorflow:latest RUN apt-get update RUN apt-get install python-opencv -y ENV APP_HOME /app WORKDIR $APP_HOME ADD . $APP_HOME
version: “3.3” services: app: build: . command: “python /app/'YOUR PYTHON FILE'.py” ports: — 8888:8888 volumes: — .:/app — /tmp/.X11-unix:/tmp/.X11-unix — /tmp/.docker.xauth:/tmp/.docker.xauth privileged: true environment: — DISPLAY=$DISPLAY devices: — /dev/video0:/dev/video0
NOTE : Here the issue is docker has no GUI so we are using X server here and access our system webcam use this command.
Today most of the Machine Learning Projects are research works. Hence Docker would be the best tool to explore all libraries, software’s without wasting our time for installation or system crashing.