|
| 1 | +## Running IEEE Boston Section class demo code |
| 2 | +Introduction to Practical Neural Networks and Deep Learning (Part 1) March 20, 2021 |
| 3 | + |
| 4 | +###### Why using docker container |
| 5 | +In order to avoid needing to give out separate instructions on how to install Python and needed packages to run the book's code on different platforms/flavors (such as Mac, Windows, Linux), |
| 6 | +it seemed easier to just give one set of instructions on how to create a docker container and how to run the demo code in it. |
| 7 | +Hopefully, docker is sufficiently ubiquitous nowadays so that installing and running docker on different platforms should be well documented. |
| 8 | + |
| 9 | +#### How to: clone repo, run docker container, run demo |
| 10 | +Clone repo locally at command line, `cd` into repo directory, `git checkout` branch that has desired setup of demo code you want to run. |
| 11 | + |
| 12 | +Acknowledgement: The repo is forked from _DeepLearningPython35_ repo of Michal Daniel Dobrzanski who ported the book's code from Python 2.7 to Python 3.5 and wrote the 'wrapper' test.py |
| 13 | +``` |
| 14 | +~ $ git clone https://github.com/clkim/DeepLearningPython35.git |
| 15 | +~ $ cd DeepLearningPython35 |
| 16 | +~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta |
| 17 | +``` |
| 18 | +In order to run the desired setup of demo code, comment in/out or add/modify the code as appropriate in `test.py` in order to specify the neural network and deep learning configuration to run. |
| 19 | + |
| 20 | +To see an example of the (flexible but somewhat hackish and minimalist) changes I made in `test.py` in order to run the demo in the chap1 branch, |
| 21 | +at command line run `git diff ea229ac 6ba2425` to see the small change committed in the branch. |
| 22 | + |
| 23 | + |
| 24 | +Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). |
| 25 | + |
| 26 | +At repo directory, start docker container _deeplearning_ (see below for how to create container). |
| 27 | +In container shell `cd` into mounted repo directory (which should be already on desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). |
| 28 | +``` |
| 29 | +~/DeepLearningPython35 $ docker container ls --all |
| 30 | +< Should see a table with column names CONTAINER ID ... NAMES, and a row with container named deeplearning > |
| 31 | +
|
| 32 | +~/DeepLearningPython35 $ docker container start -ai deeplearning |
| 33 | +(base) root@xxx:/# cd deeplearn/ |
| 34 | +(base) root@xxx:/deeplearn# python --version |
| 35 | +Python 3.8.5 |
| 36 | +(base) root@xxx:/deeplearn# conda info --env |
| 37 | +< Should see two environments: base and nndlbook > |
| 38 | +(base) root@xxx:/deeplearn# conda activate nndlbook |
| 39 | +
|
| 40 | +(nndlbook) root@xxx:/deeplearn# python3.8 test.py |
| 41 | +Epoch 0 : 8943 / 10000 |
| 42 | +Epoch 1 : 9166 / 10000 |
| 43 | +Epoch 2 : 9267 / 10000 |
| 44 | +Epoch 3 : 9340 / 10000 |
| 45 | +Epoch 4 : 9337 / 10000 |
| 46 | +Epoch 5 : 9374 / 10000 |
| 47 | +Epoch 6 : 9386 / 10000 |
| 48 | +< On my late 2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > |
| 49 | +(nndlbook) root@xxx:/deeplearn# exit |
| 50 | +exit |
| 51 | +~/DeepLearningPython35 $ |
| 52 | +``` |
| 53 | +#### How to create docker container |
| 54 | +(We want to mount a directory so Python source code is accessible from inside container; and we want to install numpy package and theano package.) |
| 55 | + |
| 56 | +Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). |
| 57 | + |
| 58 | +First run docker to download miniconda3 image. |
| 59 | +Then run docker to create the container and install the packages. |
| 60 | +``` |
| 61 | +~ $ docker pull continuumio/miniconda3 |
| 62 | +Using default tag: latest |
| 63 | +... |
| 64 | +docker.io/continuumio/miniconda3:latest |
| 65 | +
|
| 66 | +~ $ docker images |
| 67 | +< Should see a table with column names REPOSITORY ... SIZE, and a row with image repository/name continuumio/miniconda3 > |
| 68 | +
|
| 69 | +< Now cd into the repo directory, after cloning repo from github as given above > |
| 70 | +< Then run docker to create a new container layer over the downloaded image, and create a new conda environment where we install packages > |
| 71 | +~ $ cd DeepLearningPython35 |
| 72 | +~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 |
| 73 | +
|
| 74 | +(base) root@xxx:/# conda --version |
| 75 | +conda 4.9.2 |
| 76 | +(base) root@xxx:/# conda create --name nndlbook |
| 77 | +Collecting package metadata (current_repodata.json): done |
| 78 | +... |
| 79 | +Proceed ([y]/n)? y |
| 80 | +... |
| 81 | +# To activate this environment, use |
| 82 | +# |
| 83 | +# $ conda activate nndlbook |
| 84 | +... |
| 85 | +
|
| 86 | +(base) root@xxx:/# conda activate nndlbook |
| 87 | +(nndlbook) root@xxx:/# conda list |
| 88 | +# packages in environment at /opt/conda/envs/nndlbook: |
| 89 | +# |
| 90 | +# Name Version Build Channel |
| 91 | +(nndlbook) root@xxx:/# python --version |
| 92 | +Python 3.8.5 |
| 93 | +
|
| 94 | +(nndlbook) root@x:/# conda install numpy |
| 95 | +Collecting package metadata (current_repodata.json): done |
| 96 | +... |
| 97 | +Proceed ([y]/n)? y |
| 98 | +... |
| 99 | +... |
| 100 | +Executing transaction: done |
| 101 | +
|
| 102 | +(nndlbook) root@xxx:/# conda install theano |
| 103 | +Collecting package metadata (current_repodata.json): done |
| 104 | +... |
| 105 | +Proceed ([y]/n)? y |
| 106 | +... |
| 107 | +... |
| 108 | +Executing transaction: done |
| 109 | +
|
| 110 | +(nndlbook) root@xxx:/# conda list |
| 111 | +< Should see list of packages including numpy and theano > |
| 112 | +
|
| 113 | +(nndlbook) root@xxx:/# exit |
| 114 | +exit |
| 115 | +~/DeepLearningPython35 $ docker container ls --all |
| 116 | +< Should see a table with column names CONTAINER ID ... NAMES, and a row with container named deeplearning > |
| 117 | +``` |
| 118 | +___ |
| 119 | + |
1 | 120 | ## Overview |
2 | 121 |
|
3 | 122 | ### neuralnetworksanddeeplearning.com integrated scripts for Python 3.5.2 and Theano with CUDA support |
|
0 commit comments