Exemple #1
0
 def _check_tf_version(self):
     is_supported_version = False
     try:
         from tensorflow import python
         if (hasattr(python, "pywrap_tensorflow")
                 and hasattr(python.pywrap_tensorflow, "IsMklEnabled")):
             from tensorflow.python.pywrap_tensorflow import IsMklEnabled
         else:
             from tensorflow.python._pywrap_util_port import IsMklEnabled
         if IsMklEnabled() and (TF_SUPPORTED_MIN_VERSION <=
                                tf.version.VERSION):
             is_supported_version = True
     except Exception as e:
         raise ValueError(e)
     finally:
         if tf.version.VERSION > TF_SUPPORTED_MAX_VERSION:
             self.logger.warning(
                 str('Please note the {} version of Intel® Optimizations for'
                     ' TensorFlow is not fully verified!'
                     ' Suggest to use the versions'
                     ' between {} and {} if meet problem').format(
                         tf.version.VERSION, TF_SUPPORTED_MIN_VERSION,
                         TF_SUPPORTED_MAX_VERSION))
         if not is_supported_version:
             raise ValueError(
                 str('Please install Intel® Optimizations for TensorFlow'
                     ' or MKL enabled source build TensorFlow'
                     ' with version >={} and <={}').format(
                         TF_SUPPORTED_MIN_VERSION,
                         TF_SUPPORTED_MAX_VERSION))
Exemple #2
0
    def _support_bf16(self):
        """Query Software and Hardware BF16 support cabability

        """
        import tensorflow as tf
        is_supported_version = False
        from tensorflow import python
        if (hasattr(python, "pywrap_tensorflow")
                and hasattr(python.pywrap_tensorflow, "IsMklEnabled")):
            from tensorflow.python.pywrap_tensorflow import IsMklEnabled
        else:
            from tensorflow.python._pywrap_util_port import IsMklEnabled
        if IsMklEnabled() and (tf.version.VERSION >= "2.3.0"):
            is_supported_version = True
        if ((is_supported_version and CpuInfo().bf16)
                or os.getenv('FORCE_BF16') == '1'):
            return True
        return False
Exemple #3
0
 def _support_bf16(self):
     """Query Software and Hardware BF16 support cabability
     
     """
     import tensorflow as tf
     is_supported_version = False
     from tensorflow import python
     if (hasattr(python, "pywrap_tensorflow")
             and hasattr(python.pywrap_tensorflow, "IsMklEnabled")):
         from tensorflow.python.pywrap_tensorflow import IsMklEnabled
     else:
         from tensorflow.python._pywrap_util_port import IsMklEnabled
     if IsMklEnabled() and (tf.version.VERSION >= "2.3.0"):
         is_supported_version = True
     command = "cat /proc/cpuinfo | grep flags | tail -n 1"
     all_flags = subprocess.check_output(command,
                                         shell=True).strip().decode()
     if ((is_supported_version and " avx512_bf16 " in all_flags)
             or os.getenv('FORCE_BF16') == '1'):
         return True
     return False
Exemple #4
0
 def _check_tf_version(self):
     is_supported_version = False
     try:
         from tensorflow import python
         if (hasattr(python, "pywrap_tensorflow")
                 and hasattr(python.pywrap_tensorflow, "IsMklEnabled")):
             from tensorflow.python.pywrap_tensorflow import IsMklEnabled
         else:
             from tensorflow.python._pywrap_util_port import IsMklEnabled
         if IsMklEnabled() and (TF_SUPPORTED_MIN_VERSION <= tf.__version__
                                <= TF_SUPPORTED_MAX_VERSION):
             is_supported_version = True
     except Exception as e:
         raise ValueError(e)
     finally:
         if not is_supported_version:
             raise ValueError(
                 str('Please install Intel® Optimizations for TensorFlow'
                     ' or MKL enabled source build TensorFlow'
                     ' with version >={} and <={}').format(
                         TF_SUPPORTED_MIN_VERSION,
                         TF_SUPPORTED_MAX_VERSION))