Docker implementation

We'll break the Docker file and its associated shell scripts into a few steps:

  1. Under your docker folder create a file named Dockerfile and start with the following commands:
FROM base_image
RUN apt update && apt install -y python3-pydot python-pydot-ng
graphviz
RUN pip3 install ipython
RUN pip3 uninstall keras -y && pip3 install keras==2.2.1

Notice we inherit from base_image and install a few necessary packages to our development. The last line is an important point—we need to install a particular build of Keras in order to utilize the Keras contributor layers that we'll install in the next step. Essentially, there're some specific layers to these networks that haven't been folded into Keras proper.

  1. Clone and install the Keras contributor layers—install for python3
# Download and Install the Keras Contributor layers
# Some papers have layers not implemented in default keras
RUN git clone https://www.github.com/keras-team/keras-contrib.git
RUN cd keras-contrib && git checkout 04b64a47a7552f && python
setup.py install

RUN cd keras-contrib && python3 setup.py install
  1. Moving on, create a shell script called build.sh and put the following test into the file:
#/bin/bash
nvidia-docker build -t ch5 .
  1. To build our newly minted Dockerfile, simply type the following commands in the Terminal to make your build script executable and execute:
sudo chmod 775 build.sh && ./build.sh
Make sure that you are in the docker folder prior to executing these commands!
  1. To make your life easier, let's create a clean script called clean.sh:
#/bin/bash
docker rmi ch5

This script just makes it easier to clean the image if you need a rebuild in the future.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.247