You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2017/10/10 05:25:14 UTC

[incubator-mxnet] branch master updated: improve diagnose script (#8200)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7232b12  improve diagnose script (#8200)
7232b12 is described below

commit 7232b1292221adf3ed19169540f8813dcd63bb71
Author: Joshua Z. Zhang <ch...@gmail.com>
AuthorDate: Mon Oct 9 22:25:10 2017 -0700

    improve diagnose script (#8200)
    
    * catch all, with better format
    
    * do not throw, better message
    
    * fix
---
 tools/diagnose.py | 142 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 82 insertions(+), 60 deletions(-)

diff --git a/tools/diagnose.py b/tools/diagnose.py
index f1990f2..1743221 100644
--- a/tools/diagnose.py
+++ b/tools/diagnose.py
@@ -81,76 +81,98 @@ def test_connection(name, url, timeout=10):
     load_elapsed = time.time() - start
     print("Timing for {}: {}, DNS: {:.4f} sec, LOAD: {:.4f} sec.".format(name, url, dns_elapsed, load_elapsed))
 
+def check_python():
+    print('----------Python Info----------')
+    print('Version      :', platform.python_version())
+    print('Compiler     :', platform.python_compiler())
+    print('Build        :', platform.python_build())
+    print('Arch         :', platform.architecture())
+
+def check_pip():
+    print('------------Pip Info-----------')
+    try:
+        import pip
+        print('Version      :', pip.__version__)
+        print('Directory    :', os.path.dirname(pip.__file__))
+    except ImportError:
+        print('No corresponding pip install for current python.')
+
+def check_mxnet():
+    print('----------MXNet Info-----------')
+    try:
+        import mxnet
+        print('Version      :', mxnet.__version__)
+        mx_dir = os.path.dirname(mxnet.__file__)
+        print('Directory    :', mx_dir)
+        commit_hash = os.path.join(mx_dir, 'COMMIT_HASH')
+        with open(commit_hash, 'r') as f:
+            ch = f.read().strip()
+            print('Commit Hash   :', ch)
+    except ImportError:
+        print('No MXNet installed.')
+    except Exception as e:
+        import traceback
+        if not isinstance(e, IOError):
+            print("An error occured trying to import mxnet.")
+            print("This is very likely due to missing missing or incompatible library files.")
+        print(traceback.format_exc())
+
+def check_os():
+    print('----------System Info----------')
+    print('Platform     :', platform.platform())
+    print('system       :', platform.system())
+    print('node         :', platform.node())
+    print('release      :', platform.release())
+    print('version      :', platform.version())
+
+def check_hardware():
+    print('----------Hardware Info----------')
+    print('machine      :', platform.machine())
+    print('processor    :', platform.processor())
+    if sys.platform.startswith('darwin'):
+        pipe = subprocess.Popen(('sysctl', '-a'), stdout=subprocess.PIPE)
+        output = pipe.communicate()[0]
+        for line in output.split(b'\n'):
+            if b'brand_string' in line or b'features' in line:
+                print(line.strip())
+    elif sys.platform.startswith('linux'):
+        subprocess.call(['lscpu'])
+    elif sys.platform.startswith('win32'):
+        subprocess.call(['wmic', 'cpu', 'get', 'name'])
+
+def check_network(args):
+    print('----------Network Test----------')
+    if args.timeout > 0:
+        print('Setting timeout: {}'.format(args.timeout))
+        socket.setdefaulttimeout(10)
+    for region in args.region.strip().split(','):
+        r = region.strip().lower()
+        if not r:
+            continue
+        if r in REGIONAL_URLS:
+            URLS.update(REGIONAL_URLS[r])
+        else:
+            import warnings
+            warnings.warn('Region {} do not need specific test, please refer to global sites.'.format(r))
+    for name, url in URLS.items():
+        test_connection(name, url, args.timeout)
+
 if __name__ == '__main__':
     args = parse_args()
     if args.python:
-        print('----------Python Info----------')
-        print('Version      :', platform.python_version())
-        print('Compiler     :', platform.python_compiler())
-        print('Build        :', platform.python_build())
-        print('Arch         :', platform.architecture())
+        check_python()
 
     if args.pip:
-        print('------------Pip Info-----------')
-        try:
-            import pip
-            print('Version      :', pip.__version__)
-            print('Directory    :', os.path.dirname(pip.__file__))
-        except ImportError:
-            print('No corresponding pip install for current python.')
+        check_pip()
 
     if args.mxnet:
-        print('----------MXNet Info-----------')
-        try:
-            import mxnet
-            print('Version      :', mxnet.__version__)
-            mx_dir = os.path.dirname(mxnet.__file__)
-            print('Directory    :', mx_dir)
-            commit_hash = os.path.join(mx_dir, 'COMMIT_HASH')
-            with open(commit_hash, 'r') as f:
-                ch = f.read().strip()
-                print('Commit Hash   :', ch)
-        except ImportError:
-            print('No MXNet installed.')
-        except IOError:
-            pass
+        check_mxnet()
 
     if args.os:
-        print('----------System Info----------')
-        print('Platform     :', platform.platform())
-        print('system       :', platform.system())
-        print('node         :', platform.node())
-        print('release      :', platform.release())
-        print('version      :', platform.version())
+        check_os()
 
     if args.hardware:
-        print('----------Hardware Info----------')
-        print('machine      :', platform.machine())
-        print('processor    :', platform.processor())
-        if sys.platform.startswith('darwin'):
-            pipe = subprocess.Popen(('sysctl', '-a'), stdout=subprocess.PIPE)
-            output = pipe.communicate()[0]
-            for line in output.split(b'\n'):
-                if b'brand_string' in line or b'features' in line:
-                    print(line.strip())
-        elif sys.platform.startswith('linux'):
-            subprocess.call(['lscpu'])
-        elif sys.platform.startswith('win32'):
-            subprocess.call(['wmic', 'cpu', 'get', 'name'])
+        check_hardware()
 
     if args.network:
-        print('----------Network Test----------')
-        if args.timeout > 0:
-            print('Setting timeout: {}'.format(args.timeout))
-            socket.setdefaulttimeout(10)
-        for region in args.region.strip().split(','):
-            r = region.strip().lower()
-            if not r:
-                continue
-            if r in REGIONAL_URLS:
-                URLS.update(REGIONAL_URLS[r])
-            else:
-                import warnings
-                warnings.warn('Region {} do not need specific test, please refer to global sites.'.format(r))
-        for name, url in URLS.items():
-            test_connection(name, url, args.timeout)
+        check_network(args)

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].