Merge pull request #445 from dcslin/SINGA-433

SINGA-433 updated documentation about docker, dockerfile for consitent, cudnn version in dockerfile
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index bc03096..d1d8060 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -144,9 +144,8 @@
 
 IF(USE_MKLDNN)
     FIND_PATH(MKLDNN_INCLUDE_DIR NAME "mkldnn.hpp" PATHS "$ENV{CMAKE_INCLUDE_PATH}")
-    FIND_LIBRARY(MKLDNN_LIBRARIES NAME "libmkldnn.so" PATHS "$ENV{CMAKE_LIBRARY_PATH}")
-    FIND_LIBRARY(MKLML_LIBRARIES NAME "libmklml_intel.so" PATHS "$ENV{CMAKE_LIBRARY_PATH}")
+    FIND_LIBRARY(MKLDNN_LIBRARIES NAME "mkldnn" PATHS "$ENV{CMAKE_LIBRARY_PATH}")
     MESSAGE(STATUS "Found MKLDNN at ${MKLDNN_INCLUDE_DIR}")
     INCLUDE_DIRECTORIES(${MKLDNN_INCLUDE_DIR})
-    LIST(APPEND SINGA_LINKER_LIBS ${MKLDNN_LIBRARIES} ${MKLML_LIBRARIES})
+    LIST(APPEND SINGA_LINKER_LIBS ${MKLDNN_LIBRARIES})
 ENDIF()
diff --git a/doc/en/docs/docker.md b/doc/en/docs/docker.md
index 314ec4c..287e52d 100644
--- a/doc/en/docs/docker.md
+++ b/doc/en/docs/docker.md
@@ -49,28 +49,23 @@
 
 The `<TAG>` is named as
 
-    devel|runtime[-OS][-CUDA|OPENCL][-CUDNN]
+    devel|runtime[-CUDA|CPU][-CUDNN]
 
 * devel: development images with all dependent libs' header files installed and SINGA's source code; runtime: the minimal images which can run SINGA programs.
-* OS: ubuntu, ubuntu14.04, centos, centos6
-* CUDA: cuda, cuda8.0, cuda7.0
-* CUDNN: cudnn, cudnn5, cudnn4
-* OPENCL: opencl, opencl1.2
+* CUDA: cuda10.0, cuda9.0
+* CUDNN: cudnn7
 
-By default, if the version is not included in the tag, the latest stable version is used.
-The default OS is Ubuntu. The version is the latest stable version (e.g., 16.04 for now).
-For -cuda version, the **cudnn** is included by default. Their versions are also the latest stable version, i.e., cuda8.0 and cudnn5 for now.
+Here are some example tags:
 
-Here are some example tags,
+`devel-cuda9-cudnn7`, `devel-cuda9-cudnn7`, `devel-cuda10-cudnn7`, `devel-cpu`, `runtime-gpu` and `runtime-cpu`
 
-`devel`, `devel-cuda`, `runtime`, `runtime-cuda`, `devel-centos7-cuda`, `devel-ubuntu14.04`, `devel-ubuntu14.04-cuda7.5-cudnn4`
 
 Please follow the existing Dockefiles under tool/docker/ to create other Dockefiles.
 The folder structure is like
 
     level1: devel|runtime
     level2: Dockerfile, OS
-    level3: Dockerfile, CUDA|OPENCL
-    level4: CUDNN
+    level3: Dockerfile, CUDA|MKLDNN
 
-For example, the path of the Dockerfile for `devel-cuda` is `tool/docker/devel/cuda/Dockerfile`.
+
+For example, the path of the Dockerfile for `devel-cuda9-cudnn7` is `tool/docker/devel/ubuntu/cuda9/Dockerfile`.
diff --git a/tool/docker/README.md b/tool/docker/README.md
index 26763fb..287e52d 100644
--- a/tool/docker/README.md
+++ b/tool/docker/README.md
@@ -16,24 +16,56 @@
     specific language governing permissions and limitations
     under the License.
 -->
-# SINGA Docker Images
-
-## Availabe images
+# Docker Images
 
 
-| Tag | OS version | devel/runtime | Device|CUDA/CUDNN|Python|
-|:----|:-----------|:--------------|:------|:---------|:-----|
-|runtime| Ubuntu16.04|runtime|CPU|-|3.6|
-|conda-cuda9.0| Ubuntu16.04|devel|GPU|CUDA9.0+CUDNN7.1.2|3.6|
-|cuda9.0-py2| Ubuntu16.04|devel|GPU|CUDA9.0+CUDNN7.1.2|2.7|
-|cuda9.0-py3| Ubuntu18.04|devel|GPU|CUDA9.0+CUDNN7.1.2|3.6|
-|cuda10.0-py3| Ubuntu18.04|devel|GPU|CUDA10.0+CUDNN7.4.2|3.6|
+## Available tags
 
-runtime and conda-xxx image has installed miniconda3;
-cudaxxx images have installed all depedent libs using apt-get.
+* `devel`, with SINGA and the development packages installed on Ubuntu16.04 (no GPU)
+* `devel-cuda`, with SINGA, CUDA8.0, CUDNN5, and other development packages installed on Ubuntu16.04
 
-## Usage
+## Use the existing Docker images
 
-    docker pull nusdbsystem/singa:<Tag>
-    docker run -it nusdbsystem/singa:<Tag> /bin/bash
-    nvidia-docker run -it nusdbsystem/singa:<Tag> /bin/bash
+Users can pull the Docker images from Dockerhub via
+
+    docker pull apache/singa:devel
+    # or
+    docker pull apache/singa:devel-cuda
+
+Run the docker container using
+
+    docker run -it apache/singa:devel /bin/bash
+    # or
+    docker run -it apache/singa:devel-cuda /bin/bash
+
+The latest SINGA code is under the `incubator-singa` folder.
+
+## Create new Docker images from Dockerfile
+
+New Docker images could be created by executing the following command within the
+Dockerfile folder, e.g., tool/docker/devel/
+
+    docker build -t singa:<TAG> -f Dockerfile
+
+The `<TAG>` is named as
+
+    devel|runtime[-CUDA|CPU][-CUDNN]
+
+* devel: development images with all dependent libs' header files installed and SINGA's source code; runtime: the minimal images which can run SINGA programs.
+* CUDA: cuda10.0, cuda9.0
+* CUDNN: cudnn7
+
+Here are some example tags:
+
+`devel-cuda9-cudnn7`, `devel-cuda9-cudnn7`, `devel-cuda10-cudnn7`, `devel-cpu`, `runtime-gpu` and `runtime-cpu`
+
+
+Please follow the existing Dockefiles under tool/docker/ to create other Dockefiles.
+The folder structure is like
+
+    level1: devel|runtime
+    level2: Dockerfile, OS
+    level3: Dockerfile, CUDA|MKLDNN
+
+
+For example, the path of the Dockerfile for `devel-cuda9-cudnn7` is `tool/docker/devel/ubuntu/cuda9/Dockerfile`.
diff --git a/tool/docker/build.sh b/tool/docker/build.sh
index 3ed517d..d0bcaa3 100755
--- a/tool/docker/build.sh
+++ b/tool/docker/build.sh
@@ -30,8 +30,7 @@
 echo "###################"
 echo "build singa:cudax.y"
 echo "###################"
-docker build tool/docker/devel/native/ubuntu/cuda/py2 --force-rm -t nusdbsystem/singa:cuda10.0-cudnn7.4.2-py2
-docker build tool/docker/devel/native/ubuntu/cuda/py3 --force-rm -t nusdbsystem/singa:cuda10.0-cudnn7.4.2-py3
+docker build tool/docker/devel/native/ubuntu/cuda9 --force-rm -t nusdbsystem/singa:cuda9-cudnn7
 
 if [ $1 = "PUSH" ]; then
   echo "##########################################"
diff --git a/tool/docker/devel/ubuntu/cpu/py3/Dockerfile b/tool/docker/devel/ubuntu/cpu/Dockerfile
similarity index 74%
rename from tool/docker/devel/ubuntu/cpu/py3/Dockerfile
rename to tool/docker/devel/ubuntu/cpu/Dockerfile
index d61db3c..d8a6cc1 100644
--- a/tool/docker/devel/ubuntu/cpu/py3/Dockerfile
+++ b/tool/docker/devel/ubuntu/cpu/Dockerfile
@@ -35,7 +35,6 @@
         python3-pip \
         python3-setuptools \
         libgoogle-glog-dev \
-        sudo \
         cmake \
     && apt-get clean \
     && apt-get autoremove \
@@ -52,31 +51,24 @@
 RUN wget https://github.com/intel/mkl-dnn/archive/v0.18.tar.gz -P /tmp/ \
     && tar zxf /tmp/v0.18.tar.gz -C /tmp/ \
     && cd /tmp/mkl-dnn-0.18/ \
-    && cd scripts && ./prepare_mkl.sh && cd .. \
     && mkdir -p build && cd build && cmake .. \
     && make && make install
 
 # config ssh service
 RUN mkdir /var/run/sshd \
     && echo 'root:singa' | chpasswd \
-    # for ubuntu 16.04 prohibit
-    && sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
-    # SSH login fix. Otherwise user is kicked off after login
-    && sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
-    # dump environment variables into files, so that ssh can see also
-    # && env | grep _ >> /etc/environment \ 
-    && useradd -m singa && echo 'singa:singa' | chpasswd && adduser singa sudo
-RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+    && sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config \
+    && sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
+    && mkdir /root/.ssh
 
-USER singa 
 # build incubator singa
 RUN git clone https://github.com/apache/incubator-singa.git $HOME/incubator-singa \
     && cd $HOME/incubator-singa \
     && mkdir build && cd build \
     && cmake -DENABLE_TEST=ON -DUSE_PYTHON3=ON -DUSE_MKLDNN=ON ..
-RUN cd $HOME/incubator-singa/build && make && sudo make install
+RUN cd $HOME/incubator-singa/build && make && make install
 
-WORKDIR /home/singa/incubator-singa
+WORKDIR $HOME/incubator-singa
 EXPOSE 22
 
 CMD ["/usr/sbin/sshd", "-D"]
diff --git a/tool/docker/devel/ubuntu/cuda/py2/Dockerfile b/tool/docker/devel/ubuntu/cuda/py2/Dockerfile
deleted file mode 100644
index c48adf2..0000000
--- a/tool/docker/devel/ubuntu/cuda/py2/Dockerfile
+++ /dev/null
@@ -1,71 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# 
-# Change tags to build with different cuda/cudnn versions:
-FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
-
-# install dependencies
-RUN apt-get update \
-    && apt-get install -y --no-install-recommends \
-        git \
-        build-essential \
-        autoconf \
-        libtool \
-        cmake \
-        libprotobuf-dev \
-        libopenblas-dev \
-        libpcre3-dev \
-        protobuf-compiler \
-        wget \
-        openssh-server \
-        swig \
-        python-dev \
-        python-pip \
-        python-setuptools \
-    && apt-get clean \
-    && apt-get autoremove \
-    && apt-get autoclean \
-    && rm -rf /var/lib/apt/lists/* \
-    && pip install -U --no-cache \
-        pip \
-        wheel \
-        numpy \
-        setuptools \
-        protobuf \
-        future \
-    # install swig > 3.0.10 for ubuntu < 16.04
-    # RUN wget http://prdownloads.sourceforge.net/swig/swig-3.0.10.tar.gz && \
-    #     tar zxf swig-3.0.10.tar.gz && cd swig-3.0.10 && \
-    #     ./configure && make && make install
-    # set environment
-    # ENV CMAKE_INCLUDE_PATH /usr/local/cuda/include:${CMAKE_INCLUDE_PATH}
-    # ENV CMAKE_LIBRARY_PATH /usr/local/cuda/lib64:${CMAKE_LIBRARY_PATH}
-    # config ssh service
-    && mkdir /var/run/sshd \
-    && echo 'root:singa' | chpasswd \
-    # for ubuntu 14.04
-    # RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
-    # for ubuntu 16.04 prohibit
-    && sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
-    # SSH login fix. Otherwise user is kicked off after login
-    && sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
-    # dump environment variables into files, so that ssh can see also
-    && env | grep _ >> /etc/environment
-
-EXPOSE 22
-
-CMD ["/usr/sbin/sshd", "-D"]
diff --git a/tool/docker/devel/ubuntu/cuda10/py3/Dockerfile b/tool/docker/devel/ubuntu/cuda10/Dockerfile
similarity index 75%
rename from tool/docker/devel/ubuntu/cuda10/py3/Dockerfile
rename to tool/docker/devel/ubuntu/cuda10/Dockerfile
index 09cd84e..6d29f9b 100644
--- a/tool/docker/devel/ubuntu/cuda10/py3/Dockerfile
+++ b/tool/docker/devel/ubuntu/cuda10/Dockerfile
@@ -16,7 +16,14 @@
 #
 # 
 # Change tags to build with different cuda/cudnn versions:
-FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
+FROM nvidia/cuda:10.0-devel-ubuntu18.04
+
+ENV CUDNN_VERSION 7.4.2.24
+RUN apt-get update && apt-get install -y --no-install-recommends \
+        libcudnn7=$CUDNN_VERSION-1+cuda10.0 \
+        libcudnn7-dev=$CUDNN_VERSION-1+cuda10.0 && \
+    apt-mark hold libcudnn7 && \
+    rm -rf /var/lib/apt/lists/*
 
 # install dependencies
 RUN apt-get update \
@@ -36,7 +43,6 @@
         python3-pip \
         python3-setuptools \
         libgoogle-glog-dev \
-        sudo \
     && apt-get clean \
     && apt-get autoremove \
     && apt-get autoclean \
@@ -57,31 +63,24 @@
 RUN wget https://github.com/intel/mkl-dnn/archive/v0.18.tar.gz -P /tmp/ \
     && tar zxf /tmp/v0.18.tar.gz -C /tmp/ \
     && cd /tmp/mkl-dnn-0.18/ \
-    && cd scripts && ./prepare_mkl.sh && cd .. \
     && mkdir -p build && cd build && cmake .. \
     && make && make install
 
 # config ssh service
 RUN mkdir /var/run/sshd \
     && echo 'root:singa' | chpasswd \
-    # for ubuntu 16.04 prohibit
-    && sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
-    # SSH login fix. Otherwise user is kicked off after login
-    && sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
-    # dump environment variables into files, so that ssh can see also
-    && env | grep _ >> /etc/environment \
-    && useradd -m singa && echo 'singa:singa' | chpasswd && adduser singa sudo
-RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+    && sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config \
+    && sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
+    && mkdir /root/.ssh
 
-USER singa 
 # build incubator singa
 RUN git clone https://github.com/apache/incubator-singa.git $HOME/incubator-singa \
     && cd $HOME/incubator-singa \
     && mkdir build && cd build \
     && /usr/local/bin/cmake -DENABLE_TEST=ON -DUSE_CUDA=ON -DUSE_PYTHON3=ON -DUSE_MKLDNN=ON ..
-RUN cd $HOME/incubator-singa/build && make && sudo make install
+RUN cd $HOME/incubator-singa/build && make && make install
 
-WORKDIR /home/singa/incubator-singa
+WORKDIR $HOME/incubator-singa
 EXPOSE 22
 
 CMD ["/usr/sbin/sshd", "-D"]
diff --git a/tool/docker/devel/ubuntu/cuda/py3/Dockerfile b/tool/docker/devel/ubuntu/cuda9/Dockerfile
similarity index 86%
rename from tool/docker/devel/ubuntu/cuda/py3/Dockerfile
rename to tool/docker/devel/ubuntu/cuda9/Dockerfile
index dea0885..98a0a88 100644
--- a/tool/docker/devel/ubuntu/cuda/py3/Dockerfile
+++ b/tool/docker/devel/ubuntu/cuda9/Dockerfile
@@ -16,7 +16,15 @@
 #
 # 
 # Change tags to build with different cuda/cudnn versions:
-FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
+FROM nvidia/cuda:9.0-devel-ubuntu16.04
+
+ENV CUDNN_VERSION 7.4.2.24
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+        libcudnn7=$CUDNN_VERSION-1+cuda9.0 \
+        libcudnn7-dev=$CUDNN_VERSION-1+cuda9.0 && \
+    apt-mark hold libcudnn7 && \
+    rm -rf /var/lib/apt/lists/*
 
 # install dependencies
 RUN apt-get update \
@@ -35,7 +43,6 @@
         python3-pip \
         python3-setuptools \
         libgoogle-glog-dev \
-        sudo \
         cmake \
     && apt-get clean \
     && apt-get autoremove \
@@ -57,7 +64,6 @@
 RUN wget https://github.com/intel/mkl-dnn/archive/v0.18.tar.gz -P /tmp/ \
     && tar zxf /tmp/v0.18.tar.gz -C /tmp/ \
     && cd /tmp/mkl-dnn-0.18/ \
-    && cd scripts && ./prepare_mkl.sh && cd .. \
     && mkdir -p build && cd build && cmake .. \
     && make && make install
 
@@ -69,19 +75,16 @@
     # SSH login fix. Otherwise user is kicked off after login
     && sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd \
     # dump environment variables into files, so that ssh can see also
-    && env | grep _ >> /etc/environment \
-    && useradd -m singa && echo 'singa:singa' | chpasswd && adduser singa sudo
-RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+    && env | grep _ >> /etc/environment
 
-USER singa 
 # build incubator singa
 RUN git clone https://github.com/apache/incubator-singa.git $HOME/incubator-singa \
     && cd $HOME/incubator-singa \
     && mkdir build && cd build \
     && cmake -DENABLE_TEST=ON -DUSE_CUDA=ON -DUSE_MKLDNN=ON -DUSE_PYTHON3=ON ..
-RUN cd $HOME/incubator-singa/build && make && sudo make install
+RUN cd $HOME/incubator-singa/build && make && make install
 
-WORKDIR /home/singa/incubator-singa
+WORKDIR $HOME/incubator-singa
 EXPOSE 22
 
 CMD ["/usr/sbin/sshd", "-D"]
diff --git a/tool/docker/runtime/Dockerfile b/tool/docker/runtime/cpu/Dockerfile
similarity index 71%
rename from tool/docker/runtime/Dockerfile
rename to tool/docker/runtime/cpu/Dockerfile
index d250612..c4717c1 100644
--- a/tool/docker/runtime/Dockerfile
+++ b/tool/docker/runtime/cpu/Dockerfile
@@ -17,34 +17,36 @@
 # limitations under the License.
 #
 # Base unbuntu 16.04 image
-FROM ubuntu:latest
+FROM ubuntu:18.04
 
 MAINTAINER incubator-singa dev@singa.incubator.apache.org
 
 # install dependencies
 RUN apt-get update \
-    && apt-get install -y --no-install-recommends subversion git wget openssh-server bzip2\
+    && apt-get install -y --no-install-recommends subversion git wget openssh-server bzip2 \
     && apt-get clean && apt-get autoremove && apt-get autoclean \
     && rm -rf /var/lib/apt/lists/*
 
-RUN wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
+# install conda
+RUN wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O miniconda.sh;
 RUN bash miniconda.sh -b -p /root/miniconda
 ENV PATH /root/miniconda/bin:${PATH}
 RUN conda config --set always_yes yes --set changeps1 no
-RUN conda update -q conda
+RUN conda install -c nusdbsystem singa-cpu
 RUN conda install -c conda-forge sphinx
 RUN conda install -c conda-forge sphinx_rtd_theme
 RUN conda install -c conda-forge recommonmark
-RUN conda install -c nusdbsystem singa_cpu
 
-RUN mkdir /var/run/sshd
-RUN echo 'root:singa' | chpasswd
-RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
-# SSH login fix. Otherwise user is kicked off after login
-RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
 
-# dump environment variables into files, so that ssh can see also
-# RUN env | grep _ >> /etc/environment
+# config ssh service
+RUN mkdir /var/run/sshd \
+    && echo 'root:singa' | chpasswd \
+    && sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config \
+    && sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
+    && mkdir /root/.ssh
+
+# add conda bin path to login or non-login shell
+RUN echo PATH=$PATH:/root/miniconda/bin >> /etc/profile
 
 EXPOSE 22
 
diff --git a/tool/docker/runtime/Dockerfile b/tool/docker/runtime/gpu/Dockerfile
similarity index 71%
copy from tool/docker/runtime/Dockerfile
copy to tool/docker/runtime/gpu/Dockerfile
index d250612..89f7754 100644
--- a/tool/docker/runtime/Dockerfile
+++ b/tool/docker/runtime/gpu/Dockerfile
@@ -17,34 +17,37 @@
 # limitations under the License.
 #
 # Base unbuntu 16.04 image
-FROM ubuntu:latest
+FROM nvidia/cuda:9.0-devel-ubuntu16.04
 
 MAINTAINER incubator-singa dev@singa.incubator.apache.org
 
 # install dependencies
 RUN apt-get update \
-    && apt-get install -y --no-install-recommends subversion git wget openssh-server bzip2\
+    && apt-get install -y --no-install-recommends subversion git wget openssh-server bzip2 \
     && apt-get clean && apt-get autoremove && apt-get autoclean \
     && rm -rf /var/lib/apt/lists/*
 
-RUN wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
+# install conda
+RUN wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh -O miniconda.sh;
 RUN bash miniconda.sh -b -p /root/miniconda
 ENV PATH /root/miniconda/bin:${PATH}
 RUN conda config --set always_yes yes --set changeps1 no
-RUN conda update -q conda
+RUN conda install -c nusdbsystem singa-gpu
 RUN conda install -c conda-forge sphinx
 RUN conda install -c conda-forge sphinx_rtd_theme
 RUN conda install -c conda-forge recommonmark
-RUN conda install -c nusdbsystem singa_cpu
 
-RUN mkdir /var/run/sshd
-RUN echo 'root:singa' | chpasswd
-RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
-# SSH login fix. Otherwise user is kicked off after login
-RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
 
-# dump environment variables into files, so that ssh can see also
-# RUN env | grep _ >> /etc/environment
+# config ssh service
+RUN mkdir /var/run/sshd \
+    && echo 'root:singa' | chpasswd \
+    && sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config \
+    && sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
+    && mkdir /root/.ssh
+
+# add conda bin path to login or non-login shell
+RUN echo PATH=$PATH:/root/miniconda/bin >> /etc/profile
+
 
 EXPOSE 22