├── Dockerfile.cpu ├── Dockerfile.gpu ├── InstallDocker ├── docker_install1404.sh └── docker_install1604.sh ├── README.md ├── bashrc.txt ├── jupyter_notebook_config.py ├── nvidia_docker.sh └── run_jupyter.sh /Dockerfile.cpu: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | MAINTAINER Dhaval Thakkar 4 | 5 | ARG PIP=/root/anaconda3/bin/pip 6 | 7 | # Install some dependencies 8 | RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E1DD270288B4E6030699E45FA1715D88E1DF1F24 9 | RUN sudo su -c "echo 'deb http://ppa.launchpad.net/git-core/ppa/ubuntu trusty main' > /etc/apt/sources.list.d/git.list" 10 | RUN apt-get update && apt-get install -y \ 11 | git -y \ 12 | qt5-default -y \ 13 | build-essential \ 14 | cmake \ 15 | curl \ 16 | g++ \ 17 | nano \ 18 | pkg-config \ 19 | software-properties-common \ 20 | unzip \ 21 | vim \ 22 | gcc \ 23 | graphviz \ 24 | wget \ 25 | doxygen \ 26 | && \ 27 | apt-get clean && \ 28 | apt-get autoremove && \ 29 | rm -rf /var/lib/apt/lists/* 30 | 31 | 32 | #Anaconda 33 | RUN wget --quiet https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh && \ 34 | bash Anaconda3-4.4.0-Linux-x86_64.sh -b 35 | 36 | #Setup .bashrc 37 | RUN rm -r /root/.bashrc 38 | COPY bashrc.txt /root/.bashrc 39 | RUN alias brc='source ~/.bashrc' 40 | 41 | # Installing TensorFlow 42 | RUN ${PIP} --no-cache-dir install \ 43 | https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp36-cp36m-linux_x86_64.whl 44 | 45 | # Installing PyTorch 46 | RUN ${PIP} --no-cache-dir install \ 47 | http://download.pytorch.org/whl/cu75/torch-0.2.0.post3-cp36-cp36m-manylinux1_x86_64.whl && \ 48 | ${PIP} --no-cache-dir install \ 49 | torchvision 50 | 51 | # Installing Numpy for the current user (BUGFIX) 52 | RUN ${PIP} --no-cache-dir install -U numpy 53 | 54 | # Installing MXNet 55 | RUN ${PIP} --no-cache-dir install \ 56 | mxnet==0.11.0 57 | 58 | #Installing Keras 59 | RUN ${PIP} --no-cache-dir install keras 60 | 61 | # Install OpenCV 62 | RUN git clone --depth 1 https://github.com/opencv/opencv.git /root/opencv && \ 63 | cd /root/opencv && \ 64 | mkdir build && \ 65 | cd build && \ 66 | cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON .. && \ 67 | make -j"$(nproc)" && \ 68 | make install && \ 69 | ldconfig && \ 70 | echo 'ln /dev/null /dev/raw1394' >> ~/.bashrc 71 | 72 | #Setup notebook config 73 | COPY jupyter_notebook_config.py /root/.jupyter/ 74 | 75 | # Jupyter has issues with being run directly: https://github.com/ipython/ipython/issues/7062 76 | COPY run_jupyter.sh /root/ 77 | 78 | # Expose Ports for TensorBoard (6006), Ipython (8888) 79 | EXPOSE 6006 8888 80 | 81 | WORKDIR "/root" 82 | CMD ["/bin/bash"] 83 | 84 | -------------------------------------------------------------------------------- /Dockerfile.gpu: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu14.04 2 | 3 | MAINTAINER Dhaval Thakkar 4 | 5 | ARG PIP=/root/anaconda3/bin/pip 6 | 7 | # Install some dependencies 8 | RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E1DD270288B4E6030699E45FA1715D88E1DF1F24 9 | RUN sudo su -c "echo 'deb http://ppa.launchpad.net/git-core/ppa/ubuntu trusty main' > /etc/apt/sources.list.d/git.list" 10 | RUN apt-get update && apt-get install -y \ 11 | git -y \ 12 | qt5-default -y \ 13 | build-essential \ 14 | cmake \ 15 | curl \ 16 | g++ \ 17 | nano \ 18 | pkg-config \ 19 | software-properties-common \ 20 | unzip \ 21 | vim \ 22 | gcc \ 23 | graphviz \ 24 | wget \ 25 | doxygen \ 26 | && \ 27 | apt-get clean && \ 28 | apt-get autoremove && \ 29 | rm -rf /var/lib/apt/lists/* 30 | 31 | #Anaconda 32 | RUN wget --quiet https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh && \ 33 | bash Anaconda3-4.4.0-Linux-x86_64.sh -b 34 | 35 | #Setup .bashrc 36 | RUN rm -r /root/.bashrc 37 | COPY bashrc.txt /root/.bashrc 38 | RUN alias brc='source ~/.bashrc' 39 | 40 | # Installing TensorFlow 41 | RUN ${PIP} --no-cache-dir install \ 42 | https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp36-cp36m-linux_x86_64.whl 43 | 44 | # Installing PyTorch 45 | RUN ${PIP} --no-cache-dir install \ 46 | http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp36-cp36m-manylinux1_x86_64.whl && \ 47 | ${PIP} --no-cache-dir install \ 48 | torchvision 49 | 50 | # Installing Numpy for the current user (BUGFIX) 51 | RUN ${PIP} --no-cache-dir install -U numpy 52 | 53 | # Installing MXNet 54 | RUN ${PIP} --no-cache-dir install \ 55 | mxnet-cu80==0.11.0 56 | 57 | #Installing Keras 58 | RUN ${PIP} --no-cache-dir install keras 59 | 60 | # Install OpenCV 61 | RUN git clone --depth 1 https://github.com/opencv/opencv.git /root/opencv && \ 62 | cd /root/opencv && \ 63 | mkdir build && \ 64 | cd build && \ 65 | cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON .. && \ 66 | make -j"$(nproc)" && \ 67 | make install && \ 68 | ldconfig && \ 69 | echo 'ln /dev/null /dev/raw1394' >> ~/.bashrc 70 | 71 | #Setup notebook config 72 | COPY jupyter_notebook_config.py /root/.jupyter/ 73 | 74 | # Jupyter has issues with being run directly: https://github.com/ipython/ipython/issues/7062 75 | COPY run_jupyter.sh /root/ 76 | 77 | # Expose Ports for TensorBoard (6006), Ipython (8888) 78 | EXPOSE 6006 8888 79 | 80 | WORKDIR "/root" 81 | CMD ["/bin/bash"] 82 | -------------------------------------------------------------------------------- /InstallDocker/docker_install1404.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get update 3 | sudo apt-get -y install \ 4 | linux-image-extra-$(uname -r) \ 5 | linux-image-extra-virtual 6 | sudo apt-get update 7 | sudo apt-get -y install \ 8 | apt-transport-https \ 9 | ca-certificates \ 10 | curl \ 11 | software-properties-common 12 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 13 | sudo apt-key fingerprint 0EBFCD88 14 | sudo add-apt-repository \ 15 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ 16 | $(lsb_release -cs) \ 17 | stable" 18 | sudo apt-get update 19 | sudo apt-get install -y docker-ce 20 | -------------------------------------------------------------------------------- /InstallDocker/docker_install1604.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get update 3 | sudo apt-get -y install \ 4 | apt-transport-https \ 5 | ca-certificates \ 6 | curl \ 7 | software-properties-common 8 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 9 | sudo apt-key fingerprint 0EBFCD88 10 | sudo add-apt-repository \ 11 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ 12 | $(lsb_release -cs) \ 13 | stable" 14 | sudo apt-get update 15 | sudo apt-get install -y docker-ce 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Machine Learning and Deep Learning Docker Image 2 | 3 | If you're getting started with Machine Learning/Deep Learning, you know how hard it is to setup the environment just to get started. I have built this docker image to help you out. This image contains most of the tools required to do Machine Learning/Deep Learning. 4 | 5 | This image can be used on Ubuntu. Steps for installing docker and getting started with the container are given below. Also, this image can be used on AWS, GCP or any cloud platform. 6 | 7 | ## Included Libraries 8 | 9 | * Ubuntu 14.04 10 | * CUDA 8.0 (GPU version only) 11 | * cuDNN v5 (GPU version only) 12 | * [Anaconda 4.4.0 Package (Python 3.6)](https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh) [**Jupyter Notebook included**] 13 | * [Keras](https://github.com/fchollet/keras) 14 | * [Tensorflow](https://github.com/tensorflow/tensorflow) 15 | * [PyTorch](http://pytorch.org/) 16 | * [MXNet](https://mxnet.incubator.apache.org/get_started/install.html) 17 | 18 | ## To be Included 19 | 20 | * Caffe 21 | * OpenCV 22 | * CNTK 23 | 24 | #### CPU 25 | 1. Installing Docker 26 | * Installing Docker on Ubuntu 14.04: 27 |
```sudo bash InstallDocker/docker_install1404.sh``` 28 | * Installing Docker on Ubuntu 16.04 or above: 29 |
```sudo bash InstallDocker/docker_install1604.sh``` 30 | 2. Building Docker Image: 31 |
```sudo docker build -t deeplearningdockercpu -f Dockerfile.cpu .``` 32 | 3. Running the Docker Container 33 |
```sudo docker run -it -p 8888:8888 -p 6006:6006 -v /sharedfolder:/root/sharedfolder deeplearningdockercpu:latest bash``` 34 | 35 | ### GPU 36 | 1. Installing Docker 37 | * Installing Docker on Ubuntu 14.04: 38 |
```sudo bash InstallDocker/docker_install1404.sh``` 39 | * Installing Docker on Ubuntu 16.04 or above: 40 |
```sudo bash InstallDocker/docker_install1604.sh``` 41 | 2. Installing NVIDIA-Docker 42 |
```sudo bash nvidia-docker.sh``` 43 | 3. Building Docker Image 44 |
```sudo docker build -t deeplearningdockergpu -f Dockerfile.gpu .``` 45 | 4. Restarting Nvidia-docker 46 |
```sudo systemctl restart nvidia-docker``` 47 | 4. Running the Docker Container 48 |
```sudo nvidia-docker run -it -p 8888:8888 -p 6006:6006 -v /sharedfolder:/root/sharedfolder deeplearningdockergpu:latest bash``` 49 | 50 | ### Running Jupyter notebook 51 | **```jupyter notebook --allow-root```** 52 | 53 | *Note*: You can remove __```-v /sharedfolder:/root/sharedfolder```__ from CPU as well as GPU if you're running the container on cloud. This command is to just link your local files on the container. 54 | 55 | ### Some Handy commands 56 | 1. Removing all containers 57 |
```sudo docker rm $(sudo docker ps -a -f status=exited -q)``` 58 | 2. Removing all images 59 |
```sudo docker rmi $(sudo docker images -a -q)``` 60 | 61 | 62 | ##### Issues 63 | **If there is any issue, please feel free to open an issue on GitHub or contact me on dhaval.thakkar@somaiya.edu** 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /bashrc.txt: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines in the history. See bash(1) for more options 9 | # ... or force ignoredups and ignorespace 10 | HISTCONTROL=ignoredups:ignorespace 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=1000 17 | HISTFILESIZE=2000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # make less more friendly for non-text input files, see lesspipe(1) 24 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 25 | 26 | # set variable identifying the chroot you work in (used in the prompt below) 27 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 28 | debian_chroot=$(cat /etc/debian_chroot) 29 | fi 30 | 31 | # set a fancy prompt (non-color, unless we know we "want" color) 32 | case "$TERM" in 33 | xterm-color) color_prompt=yes;; 34 | esac 35 | 36 | # uncomment for a colored prompt, if the terminal has the capability; turned 37 | # off by default to not distract the user: the focus in a terminal window 38 | # should be on the output of commands, not on the prompt 39 | #force_color_prompt=yes 40 | 41 | if [ -n "$force_color_prompt" ]; then 42 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 43 | # We have color support; assume it's compliant with Ecma-48 44 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 45 | # a case would tend to support setf rather than setaf.) 46 | color_prompt=yes 47 | else 48 | color_prompt= 49 | fi 50 | fi 51 | 52 | if [ "$color_prompt" = yes ]; then 53 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 54 | else 55 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 56 | fi 57 | unset color_prompt force_color_prompt 58 | 59 | # If this is an xterm set the title to user@host:dir 60 | case "$TERM" in 61 | xterm*|rxvt*) 62 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 63 | ;; 64 | *) 65 | ;; 66 | esac 67 | 68 | # enable color support of ls and also add handy aliases 69 | if [ -x /usr/bin/dircolors ]; then 70 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 71 | alias ls='ls --color=auto' 72 | #alias dir='dir --color=auto' 73 | #alias vdir='vdir --color=auto' 74 | 75 | alias grep='grep --color=auto' 76 | alias fgrep='fgrep --color=auto' 77 | alias egrep='egrep --color=auto' 78 | fi 79 | 80 | # some more ls aliases 81 | alias ll='ls -alF' 82 | alias la='ls -A' 83 | alias l='ls -CF' 84 | 85 | # Alias definitions. 86 | # You may want to put all your additions into a separate file like 87 | # ~/.bash_aliases, instead of adding them here directly. 88 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 89 | 90 | if [ -f ~/.bash_aliases ]; then 91 | . ~/.bash_aliases 92 | fi 93 | 94 | # enable programmable completion features (you don't need to enable 95 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 96 | # sources /etc/bash.bashrc). 97 | #if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 98 | # . /etc/bash_completion 99 | #fi 100 | 101 | export PATH="$HOME/anaconda3/bin:$PATH" 102 | -------------------------------------------------------------------------------- /jupyter_notebook_config.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | import os 16 | from IPython.lib import passwd 17 | 18 | c.NotebookApp.ip = '*' 19 | c.NotebookApp.port = 8888 20 | c.NotebookApp.open_browser = False 21 | c.MultiKernelManager.default_kernel_name = 'python2' 22 | 23 | # sets a password if PASSWORD is set in the environment 24 | if 'PASSWORD' in os.environ: 25 | c.NotebookApp.password = passwd(os.environ['PASSWORD']) 26 | del os.environ['PASSWORD'] 27 | -------------------------------------------------------------------------------- /nvidia_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install nvidia-docker and nvidia-docker-plugin 4 | sudo apt install -y nvidia-cuda-toolkit 5 | sudo apt install -y nvidia-modprobe 6 | wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb 7 | sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb 8 | 9 | # Test nvidia-smi 10 | nvidia-docker run --rm nvidia/cuda nvidia-smi 11 | 12 | 13 | -------------------------------------------------------------------------------- /run_jupyter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # ============================================================================== 16 | 17 | 18 | jupyter notebook "$@" 19 | --------------------------------------------------------------------------------