当前位置: 首页 > 知识库问答 >
问题:

MacOS上的Tensorflow:您的CPU支持该Tensorflow二进制文件未编译使用的指令:AVX2 FMA

佴普松
2023-03-14

我试着用这些说明来验证我的mac tensorflowhttps://www.tensorflow.org/install/install_mac#ValidateYourInstallation

但要产生这样的结果。可以吗?令人不快的我该怎么解决这个问题?谢谢

  • sess=tf。会话()

您的CPU支持该TensorFlow二进制文件未编译使用的指令:AVX2 FMA

  • 打印(sess.run(你好))

“你好,TensorFlow!”

Mac OS版本:MacOS High塞拉利昂10.13.6

以下是完整的安装和验证输出:

usermacbook:tensorflowve someuser$ python3 -m venv . 
usermacbook:tensorflowve someuser$ source bin/activate
(tensorflowve) usermacbook:tensorflowve someuser$ pip3 install --upgrade tensorflow
Collecting tensorflow
  Downloading https://files.pythonhosted.org/packages/57/38/96ee343729363297d62311272adc28b466d30f74c87dc645badb0102af56/tensorflow-1.9.0-cp36-cp36m-macosx_10_11_x86_64.whl (48.9MB)
    100% |████████████████████████████████| 48.9MB 30kB/s 
Collecting termcolor>=1.1.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting protobuf>=3.4.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/6d/7e/51c91b28cb8446ebd7231d375a2025bca4c59d15ddc0cf2dd0867b400cd7/protobuf-3.6.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 986kB/s 
Collecting absl-py>=0.1.6 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/96/5d/18feb90462c8edaae71305716c7e8bac479fc9dface63221f808a6b95880/absl-py-0.3.0.tar.gz (84kB)
    100% |████████████████████████████████| 92kB 3.7MB/s 
Collecting gast>=0.2.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/5c/78/ff794fcae2ce8aa6323e789d1f8b3b7765f601e7702726f430e814822b96/gast-0.2.0.tar.gz
Collecting grpcio>=1.8.6 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/c2/bc/31fb22c3dcccf018341a88bb9edc642a9b78bdedf9153bd3edc0d8e2f070/grpcio-1.14.0-cp36-cp36m-macosx_10_7_intel.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 654kB/s 
Collecting tensorboard<1.10.0,>=1.9.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/9e/1f/3da43860db614e294a034e42d4be5c8f7f0d2c75dc1c428c541116d8cdab/tensorboard-1.9.0-py3-none-any.whl (3.3MB)
    100% |████████████████████████████████| 3.3MB 425kB/s 
Collecting numpy>=1.13.3 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/6a/d5/218414f0f41cb3f183d55d68dbcd996fa3602d5849bdf2ad6c059e98fa68/numpy-1.15.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (24.5MB)
    100% |████████████████████████████████| 24.5MB 59kB/s 
Collecting setuptools<=39.1.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl (566kB)
    100% |████████████████████████████████| 573kB 1.6MB/s 
Collecting six>=1.10.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting astor>=0.6.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Collecting wheel>=0.26 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
    100% |████████████████████████████████| 51kB 4.0MB/s 
Collecting werkzeug>=0.11.10 (from tensorboard<1.10.0,>=1.9.0->tensorflow)
  Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
    100% |████████████████████████████████| 327kB 2.0MB/s 
Collecting markdown>=2.6.8 (from tensorboard<1.10.0,>=1.9.0->tensorflow)
  Downloading https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl (78kB)
    100% |████████████████████████████████| 81kB 3.7MB/s 
Installing collected packages: termcolor, setuptools, six, protobuf, absl-py, gast, grpcio, numpy, werkzeug, markdown, wheel, tensorboard, astor, tensorflow
  Running setup.py install for termcolor ... done
  Found existing installation: setuptools 28.8.0
    Uninstalling setuptools-28.8.0:
      Successfully uninstalled setuptools-28.8.0
  Running setup.py install for absl-py ... done
  Running setup.py install for gast ... done
Successfully installed absl-py-0.3.0 astor-0.7.1 gast-0.2.0 grpcio-1.14.0 markdown-2.6.11 numpy-1.15.0 protobuf-3.6.0 setuptools-39.1.0 six-1.11.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(tensorflowve) usermacbook:tensorflowve someuser$ python
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct  3 2017, 00:32:08) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2018-08-04 09:28:35.905544: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
>>> print(sess.run(hello))
b'Hello, TensorFlow!'

共有3个答案

姜运珧
2023-03-14
import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf
颜英博
2023-03-14

这不是一个错误。Tensorflow运行得很好。

这是一个警告,说明Tensorflow没有利用CPU上的一些高级指令,因为它的二进制文件被编译为不使用这些指令(因此可以在旧的CPU上运行)。

你的选择是:

  1. 别理它

如果您希望在CPU上执行大量计算,#3可能是有意义的:它可以在一定程度上提高性能。然而,这需要时间和精力,所以我不推荐初学者使用它:只需按原样使用Tensorflow即可。

P. s. b'Hello, TensorFlow!'也可以。请参见:字符串常量的打印总是与TensorFlow中的b连接

张兴旺
2023-03-14

使用高级指令编译的Tensorflow比未优化的代码运行速度快40%,因此请不要忽略此消息!

我建议从源代码构建TF,以下是下载、编译和安装v2的步骤。0测试版,包括已编译版本的链接。whl文件。

首先,卸载默认版本:

sudo pip3 uninstall protobuf
sudo pip3 uninstall tensorflow

在临时文件夹中,克隆Tensorflow:

git clone https://github.com/tensorflow/tensorflow 
git checkout r2.0

安装TensorFlow pip软件包依赖项:

pip3 install -U --user pip six numpy wheel setuptools mock future>=0.17.1
pip3 install -U --user keras_applications==1.0.6 --no-deps
pip3 install -U --user keras_preprocessing==1.0.5 --no-deps

安装用于编译TensorFlow的构建工具Bazel。下载bazel-0.26.0-installer-darwin-x86_64后。上海:

chmod +x bazel-0.26.0-installer-darwin-x86_64.sh ./bazel-0.26.0-installer-darwin-x86_64.sh --user export PATH="$PATH:$HOME/bin" bazel version

通过在TensorFlow源代码树的根目录下运行以下命令来配置系统构建:

./configure

使用bazel使TensorFlow软件包生成器仅支持CPU:

bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-msse4.2 //tensorflow/tools/pip_package:build_pip_package

bazel build命令创建一个名为build_pip_package的可执行文件——这是构建pip包的程序。如下图所示运行可执行文件以构建一个。whl包位于/tmp/tensorflow_pkg目录中。

要从发布分支生成,请执行以下操作:

./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

输出控制盘文件位于:/tmp/tensorflow_pkg中。您可以从这里下载该文件,并尝试直接安装

pip3 install /tmp/tensorflow_pkg/tensorflow-2.0.0b1-cp37-cp37m-macosx_10_14_x86_64.whl 

cd从该目录中退出,现在运行此操作不会产生任何警告:

python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

最初的帖子发表在这里。

 类似资料:
  • 我是TensorFlow的新手。我最近安装了它(Windows CPU版本),收到以下消息: 成功安装TensorFlow-1.4.0 TensorFlow-TensorBoard-0.4.0 RC2 当我想跑的时候 (我是通过https://github.com/tensorflow/tensorflow找到的) 我收到以下消息: 2017-11-02 01:56:21.698935:I C:\

  • 刚刚安装了Cuda,使用我的GPU获取Tensorflow。我按照上面的说明做了https://www.tensorflow.org/install/gpu并在上运行了Cuda测试https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/(deviceQuery和bandwidthTest)这两个测试都很好。 当我

  • 本文向大家介绍解决Tensorflow 使用时cpu编译不支持警告的问题,包括了解决Tensorflow 使用时cpu编译不支持警告的问题的使用技巧和注意事项,需要的朋友参考一下 使用TensorFlow模块时,弹出错误Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AV

  • 在导入python2.7中的tenstorflow后,我使用以下命令:

  • 问题内容: 这是从运行脚本以检查Tensorflow是否正常运行时收到的消息: 我注意到它提到了SSE4.2和AVX, 什么是SSE4.2和AVX? 这些SSE4.2和AVX如何改善Tensorflow任务的CPU计算。 如何使用这两个库使Tensorflow进行编译? 问题答案: 我只是遇到了同样的问题,似乎的建议并未涵盖SSE4.2支持,添加就足够了。最后,我成功建立了 没有任何警告或错误。

  • 这是运行脚本检查Tensorflow是否工作时收到的消息: 我注意到它提到了SSE4。2和AVX, 什么是SSE4。2和AVX 这些是怎么做的。2和AVX改进了Tensorflow任务的CPU计算 如何使用这两个库来编译Tensorflow