【问题标题】:TensorFlow.js: How to avoid `Your CPU supports instructions ... AVX AVX2`?TensorFlow.js:如何避免`你的 CPU 支持指令...... AVX AVX2`?
【发布时间】:2018-09-09 09:40:21
【问题描述】:

环境:

  • Windows 10 x64,
  • Node.js v10,
  • @tensorflow/tfjs-node v0.1.15

我正在尝试在 Node.js 上使用 tensorflow.js。

我安装了tfjs-node,它自动构建成功(node-gyp),但运行时收到以下错误:

tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

Python版本中的类似问题可以在这里找到:

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

目前,我不关心性能,所以我只想禁用警告,不要启用 AVX/FMA。在 JavaScript 中,我应该怎么做?

【问题讨论】:

    标签: javascript tensorflow


    【解决方案1】:

    运行前设置环境变量。

    窗户:

    $ set TF_CPP_MIN_LOG_LEVEL=2

    Linux/MacOS:

    $ export TF_CPP_MIN_LOG_LEVEL=2

    【讨论】:

    • 嗯。这如何解决问题?看起来它只是阻止记录?
    • @Jude Desir 是的,它只是阻止记录。该日志似乎处于警告级别或更低,只是提示用户他们的程序可以运行得更快。所以我们可以通过调整loglevel来避免它的输出。
    • 因为,我对你的陈述感到困惑。我添加此评论是为了更清楚地说明您提出的建议,以避免将来出现任何混淆。创建一个名为“TF_CPP_MIN_LOG_LEVEL”的系统变量,并将变量值设置为“2”
    【解决方案2】:

    首先列出您使用conda list 命令拥有的包(Tensorflow 和相关)。

    >> conda list
    This command output with below tensorflow version
    tblib                     1.3.2            py36h30f5020_0
    tensorboard               1.13.1                    <pip>
    tensorflow                1.13.1                    <pip>
    tensorflow-estimator      1.13.0                    <pip>
    

    注意:我省略了一些不需要的软件包列表

    Installing collected packages: tensorflow Successfully installed tensorflow-1.13.1
    You are using pip version 18.0, however version 19.0.3 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    
    (base) C:\Users\shashi>python
    Python 3.6.6 |Anaconda custom (64-bit)| (default, Jun 28 2018, 11:27:44) [MSC v.1900 
    64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import tensorflow as tf
    >>> hello = tf.constant('Hello Tensorflow')
    >>> sess = tf.Session()
    I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions 
    that this TensorFlow binary was not compiled to use: AVX2
    >>> import os
    >>> import os
    >>> os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    >>> hello = tf.constant('Hello Tensorflow')
    >>> sess = tf.Session()
    >>> print(sess.run(hello))
    b'Hello Tensorflow'
    

    设置os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'的值后,代码运行正常。

    如果 Jupyter 也抛出错误,则关闭打开的 Jupyter 笔记本并再次重新打开它们。一切都会好起来的。

    【讨论】:

      猜你喜欢
      • 2016-09-25
      • 2019-04-25
      • 2018-04-14
      • 1970-01-01
      • 1970-01-01
      • 2016-08-12
      • 1970-01-01
      相关资源
      最近更新 更多