Repository: chainer/chainer

Issue:
Add requirements check for ideep4py
Add requirements check for iDeep4py as we do in cupy.
Refs #4933


Discussion:
Refs https://github.com/intel/ideep/issues/13

Resolving patch:
diff --git a/chainer/_runtime_info.py b/chainer/_runtime_info.py
--- a/chainer/_runtime_info.py
+++ b/chainer/_runtime_info.py
@@ -6,6 +6,7 @@
 
 import chainer
 from chainer.backends import cuda
+from chainer.backends import intel64
 
 
 class _RuntimeInfo(object):
@@ -13,6 +14,7 @@ class _RuntimeInfo(object):
     chainer_version = None
     numpy_version = None
     cuda_info = None
+    ideep_version = None
 
     def __init__(self):
         self.chainer_version = chainer.__version__
@@ -22,6 +24,10 @@ def __init__(self):
             self.cuda_info = cuda.cupyx.get_runtime_info()
         else:
             self.cuda_info = None
+        if intel64.is_ideep_available():
+            self.ideep_version = intel64.ideep.__version__
+        else:
+            self.ideep_version = None
 
     def __str__(self):
         s = six.StringIO()
@@ -34,6 +40,10 @@ def __str__(self):
             s.write('''CuPy:\n''')
             for line in str(self.cuda_info).splitlines():
                 s.write('''  {}\n'''.format(line))
+        if self.ideep_version is None:
+            s.write('''iDeep: Not Available\n''')
+        else:
+            s.write('''iDeep: {}\n'''.format(self.ideep_version))
         return s.getvalue()
 
 
diff --git a/chainer/backends/intel64.py b/chainer/backends/intel64.py
--- a/chainer/backends/intel64.py
+++ b/chainer/backends/intel64.py
@@ -10,9 +10,10 @@
 try:
     import ideep4py as ideep  # NOQA
     from ideep4py import mdarray  # NOQA
-    _ideep_version = 0
+    _ideep_version = 2 if hasattr(ideep, '__version__') else 1
 except ImportError as e:
     _error = e
+    _ideep_version = None
 
     class mdarray(object):
         pass  # for type testing
@@ -31,10 +32,9 @@ def is_ideep_available():
     """Returns if iDeep is available.
 
     Returns:
-        bool: ``True`` if iDeep is installed.
+        bool: ``True`` if the supported version of iDeep is installed.
     """
-
-    return _ideep_version is not None
+    return _ideep_version is not None and _ideep_version == 2
 
 
 def check_ideep_available():
@@ -53,6 +53,10 @@ def check_ideep_available():
         raise RuntimeError(
             'iDeep is not available.\n'
             'Reason: {}: {}'.format(type(_error).__name__, msg))
+    elif _ideep_version != 2:
+        raise RuntimeError(
+            'iDeep is not available.\n'
+            'Reason: Unsupported iDeep version ({})'.format(_ideep_version))
 
 
 def should_use_ideep(level):
@@ -70,7 +74,7 @@ def should_use_ideep(level):
         bool: ``True`` if the caller should use iDeep.
 
     """
-    if _ideep_version is None:
+    if not is_ideep_available():
         return False
 
     # TODO(niboshi):
@@ -120,7 +124,7 @@ def inputs_all_ready(inputs, supported_ndim=(2, 4)):
     def _is_supported_array_type(a):
         return isinstance(a, ideep.mdarray) or ideep.check_type([a])
 
-    if _ideep_version is None:
+    if not is_ideep_available():
         return False
 
     inputs = [x.data if isinstance(x, chainer.variable.Variable)


Test patch: