You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@singa.apache.org by wa...@apache.org on 2019/03/15 06:21:52 UTC

[incubator-singa] branch master updated: SINGA-429 Added CPU devel Dockerfile

This is an automated email from the ASF dual-hosted git repository.

wangwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-singa.git


The following commit(s) were added to refs/heads/master by this push:
     new 8c6fdc3  SINGA-429 Added CPU devel Dockerfile
     new 63017de  Merge pull request #441 from dcslin/SINGA-429-cpu
8c6fdc3 is described below

commit 8c6fdc308587582068d810b6067971ed5ed83a09
Author: shicong <sh...@comp.nus.edu.sg>
AuthorDate: Thu Mar 14 13:53:44 2019 +0800

    SINGA-429 Added CPU devel Dockerfile
    
    minor unit test fix
    Ref SINGA-429.SINGA-431
---
 cmake/Dependencies.cmake                           |  4 ++-
 test/singa/test_tensor.cc                          |  3 +-
 .../native/ubuntu/{cuda10 => cpu}/py3/Dockerfile   | 32 ++++++++++------------
 .../docker/devel/native/ubuntu/cuda/py3/Dockerfile | 26 ++++++++++--------
 .../devel/native/ubuntu/cuda10/py3/Dockerfile      | 20 +++++++-------
 5 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index f66b42f..bc03096 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -145,6 +145,8 @@ ENDIF()
 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}")
+    MESSAGE(STATUS "Found MKLDNN at ${MKLDNN_INCLUDE_DIR}")
     INCLUDE_DIRECTORIES(${MKLDNN_INCLUDE_DIR})
-    LIST(APPEND SINGA_LINKER_LIBS ${MKLDNN_LIBRARIES})
+    LIST(APPEND SINGA_LINKER_LIBS ${MKLDNN_LIBRARIES} ${MKLML_LIBRARIES})
 ENDIF()
diff --git a/test/singa/test_tensor.cc b/test/singa/test_tensor.cc
index e31d99b..aa15454 100644
--- a/test/singa/test_tensor.cc
+++ b/test/singa/test_tensor.cc
@@ -121,7 +121,8 @@ TEST(TensorClass, Clone) {
 TEST(TensorClass, T) {
   Tensor t(Shape{2,3});
   EXPECT_FALSE(t.transpose());
-  Tensor o = t.T();
+  Tensor o = t.T(); // o = t = {3,2}
+  t.T(); // t = {2,3}
   EXPECT_EQ(true, o.transpose());
   EXPECT_EQ(t.block(), o.block());
   EXPECT_EQ(t.data_type(), o.data_type());
diff --git a/tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile b/tool/docker/devel/native/ubuntu/cpu/py3/Dockerfile
similarity index 71%
copy from tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile
copy to tool/docker/devel/native/ubuntu/cpu/py3/Dockerfile
index 6c8e180..d61db3c 100644
--- a/tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile
+++ b/tool/docker/devel/native/ubuntu/cpu/py3/Dockerfile
@@ -14,9 +14,8 @@
 # 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:10.0-cudnn7-devel-ubuntu18.04
+
+FROM ubuntu:18.04
 
 # install dependencies
 RUN apt-get update \
@@ -37,6 +36,7 @@ RUN apt-get update \
         python3-setuptools \
         libgoogle-glog-dev \
         sudo \
+        cmake \
     && apt-get clean \
     && apt-get autoremove \
     && apt-get autoclean \
@@ -47,30 +47,24 @@ RUN apt-get update \
         setuptools \
         protobuf \
         future
-# install cmake to correctly find Cuda 10
-RUN wget https://github.com/Kitware/CMake/releases/download/v3.12.2/cmake-3.12.2.tar.gz -P /tmp/ \
-    && tar zxf /tmp/cmake-3.12.2.tar.gz -C /tmp/ \
-    && cd /tmp/cmake-3.12.2/ && ./bootstrap && make -j4 && 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
+
 # install mkldnn
-RUN git clone https://github.com/intel/mkl-dnn.git /tmp/mkl-dnn \
-    && cd /tmp/mkl-dnn \
+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 $CMAKE_OPTIONS .. \
+    && mkdir -p build && cd build && cmake .. \
     && make && make install
+
+# config ssh service
 RUN 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 \ 
+    # && env | grep _ >> /etc/environment \ 
     && useradd -m singa && echo 'singa:singa' | chpasswd && adduser singa sudo
 RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
 
@@ -79,9 +73,11 @@ USER 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 ..
+    && cmake -DENABLE_TEST=ON -DUSE_PYTHON3=ON -DUSE_MKLDNN=ON ..
 RUN cd $HOME/incubator-singa/build && make && sudo make install
 
+WORKDIR /home/singa/incubator-singa
 EXPOSE 22
 
 CMD ["/usr/sbin/sshd", "-D"]
+
diff --git a/tool/docker/devel/native/ubuntu/cuda/py3/Dockerfile b/tool/docker/devel/native/ubuntu/cuda/py3/Dockerfile
index 625a904..dea0885 100644
--- a/tool/docker/devel/native/ubuntu/cuda/py3/Dockerfile
+++ b/tool/docker/devel/native/ubuntu/cuda/py3/Dockerfile
@@ -25,7 +25,6 @@ RUN apt-get update \
         build-essential \
         autoconf \
         libtool \
-        cmake \
         libprotobuf-dev \
         libopenblas-dev \
         libpcre3-dev \
@@ -37,6 +36,7 @@ RUN apt-get update \
         python3-setuptools \
         libgoogle-glog-dev \
         sudo \
+        cmake \
     && apt-get clean \
     && apt-get autoremove \
     && apt-get autoclean \
@@ -47,23 +47,23 @@ RUN apt-get update \
         setuptools \
         protobuf \
         future
+
 # install swig > 3.0.10
 RUN wget http://prdownloads.sourceforge.net/swig/swig-3.0.10.tar.gz -P /tmp/ \
     && tar zxf /tmp/swig-3.0.10.tar.gz -C /tmp/ \
     && cd /tmp/swig-3.0.10 && ./configure && make && make install
-    # 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
+
 # install mkldnn
-RUN git clone https://github.com/intel/mkl-dnn.git /tmp/mkl-dnn \
-    && cd /tmp/mkl-dnn \
+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 $CMAKE_OPTIONS .. \
+    && mkdir -p build && cd build && cmake .. \
     && make && make install
+
+# config ssh service
 RUN 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
@@ -76,10 +76,12 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
 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 .. \
-    && cd $HOME/incubator-singa/build && make && sudo make install
+    && 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
 
+WORKDIR /home/singa/incubator-singa
 EXPOSE 22
 
 CMD ["/usr/sbin/sshd", "-D"]
diff --git a/tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile b/tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile
index 6c8e180..09cd84e 100644
--- a/tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile
+++ b/tool/docker/devel/native/ubuntu/cuda10/py3/Dockerfile
@@ -47,30 +47,29 @@ RUN apt-get update \
         setuptools \
         protobuf \
         future
+
 # install cmake to correctly find Cuda 10
 RUN wget https://github.com/Kitware/CMake/releases/download/v3.12.2/cmake-3.12.2.tar.gz -P /tmp/ \
     && tar zxf /tmp/cmake-3.12.2.tar.gz -C /tmp/ \
     && cd /tmp/cmake-3.12.2/ && ./bootstrap && make -j4 && 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
+
 # install mkldnn
-RUN git clone https://github.com/intel/mkl-dnn.git /tmp/mkl-dnn \
-    && cd /tmp/mkl-dnn \
+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 $CMAKE_OPTIONS .. \
+    && mkdir -p build && cd build && cmake .. \
     && make && make install
+
+# config ssh service
 RUN 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 \ 
+    && env | grep _ >> /etc/environment \
     && useradd -m singa && echo 'singa:singa' | chpasswd && adduser singa sudo
 RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
 
@@ -82,6 +81,7 @@ RUN git clone https://github.com/apache/incubator-singa.git $HOME/incubator-sing
     && /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
 
+WORKDIR /home/singa/incubator-singa
 EXPOSE 22
 
 CMD ["/usr/sbin/sshd", "-D"]