You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/12/25 20:49:24 UTC

[GitHub] szha closed pull request #9153: Mkl fix pr (fix an issue in prepare_mkl.sh and add test case)

szha closed pull request #9153: Mkl fix pr (fix an issue in prepare_mkl.sh and add test case)
URL: https://github.com/apache/incubator-mxnet/pull/9153
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/Jenkinsfile b/Jenkinsfile
index 731e288372..aee091f0d8 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -119,6 +119,22 @@ def python3_gpu_ut(docker_type) {
   }
 }
 
+// Python 2
+def python2_mklml_ut(docker_type) {
+  timeout(time: max_time, unit: 'MINUTES') {
+    sh "${docker_run} ${docker_type} find . -name '*.pyc' -type f -delete"
+    sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-2.7 --with-timer --verbose tests/python/cpu"
+  }
+}
+
+// Python 3
+def python3_mklml_ut(docker_type) {
+  timeout(time: max_time, unit: 'MINUTES') {
+    sh "${docker_run} ${docker_type} find . -name '*.pyc' -type f -delete"
+    sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-3.4 --with-timer --verbose tests/python/cpu"
+  }
+}
+
 try {
   stage("Sanity Check") {
     timeout(time: max_time, unit: 'MINUTES') {
@@ -334,6 +350,7 @@ try {
           init_git()
           unpack_lib('mklml_cpu')
           python2_ut('cpu_mklml')
+          python2_mklml_ut('cpu_mklml')
         }
       }
     },
@@ -343,6 +360,7 @@ try {
           init_git()
           unpack_lib('mklml_gpu')
           python2_gpu_ut('gpu_mklml')
+          python2_mklml_ut('gpu_mklml')
         }
       }
     },
@@ -352,6 +370,7 @@ try {
           init_git()
           unpack_lib('mklml_cpu')
           python3_ut('cpu_mklml')
+          python3_mklml_ut('cpu_mklml')
         }
       }
     },
@@ -361,6 +380,7 @@ try {
           init_git()
           unpack_lib('mklml_gpu')
           python3_gpu_ut('gpu_mklml')
+          python3_mklml_ut('gpu_mklml')
         }
       }
     },
diff --git a/prepare_mkl.sh b/prepare_mkl.sh
index 97a1e49236..e048f5954c 100755
--- a/prepare_mkl.sh
+++ b/prepare_mkl.sh
@@ -115,7 +115,7 @@ if [ -z $MKLROOT ]; then
 fi
 
 # Check what MKL lib we have in MKLROOT
-if [ -z `find $MKLROOT -name libmklml_gnu.so -o -name libmklml.dylib -print -quit` ]; then
+if [ -z `find $MKLROOT \( -name libmklml_gnu.so -o -name libmklml.dylib \) -print -quit` ]; then
   USE_MKLML=0
 elif [ -z `find $MKLROOT -name libmkl_core.so -print -quit` ]; then
   USE_MKLML=1
diff --git a/tests/python/cpu/test_mklml.py b/tests/python/cpu/test_mklml.py
new file mode 100644
index 0000000000..decd5b1c98
--- /dev/null
+++ b/tests/python/cpu/test_mklml.py
@@ -0,0 +1,58 @@
+# 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.
+
+"""
+MKLML related test cases
+"""
+
+import logging
+import os
+from sys import platform
+
+def test_mklml_install():
+    """
+    This test will verify that MXNet is built/installed correctly when 
+    compiled with Intel MKLML library. The method will try to import 
+    the mxnet module and see if the mklml library is mapped to this 
+    process's address space.
+    """
+    logging.basicConfig(level=logging.INFO)
+    
+    if not platform.startswith('linux'):
+        logging.info("Bypass mklml install test for non-Linux OS")
+        return
+
+    try:
+        #pylint: disable=unused-variable
+        import mxnet as mx
+    except (ImportError, OSError) as e:
+        assert 0, "Import mxnet error: %s. Please double check your build/" \
+               "install steps or environment variable settings" % str(e)
+
+    pid = os.getpid()
+    rc = os.system("cat /proc/" + str(pid) + \
+                       "/maps | grep libmklml_ > /dev/null")
+
+    if rc == 0:
+        logging.info("MXNet is built/installed correctly with MKLML")
+    else:
+        assert 0, "MXNet is built/installed incorrectly with MKLML, please " \
+               "double check your build/install steps or environment " \
+               "variable settings"
+
+if __name__ == '__main__':
+    test_mklml_install()


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services