TensorFlow CPU环境 SSE/AVX/FMA 指令集编译

sess.run()出现如下Warning

W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

# 通过pip install tensorflow 来安装tf在 sess.run() 的时候可能会出现
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

这说明你的machine支持这些指令集但是TensorFlow在编译的时候并没有加入这些指令集,需要手动编译才能够介入这些指令集。

# 1. 下载最新的 TensorFlow
$ git clone https://github.com/tensorflow/tensorflow # 2. 安装 bazel
# mac os
$ brew install bazel # ubuntu
$ sudo apt-get update && sudo apt-get install bazel # Windows
$ choco install bazel # 3. Install TensorFlow Python dependencies
# 如果使用的是Anaconda这部可以跳过 # mac os
$ pip install six numpy wheel
$ brew install coreutils # 安装coreutils for cuda
$ sudo xcode-select -s /Applications/Xcode.app # set build tools # ubuntu
sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel
sudo apt-get install libcupti-dev # 4. 开始编译TensorFlow # 4.1 configure
$ cd tensorflow # cd to the top-level directory created
# configure 的时候要选择一些东西是否支持,这里建议都选N,不然后面会包错,如果支持显卡,就在cuda的时候选择y
$ ./configure # configure # 4.2 bazel build
# CUP-only
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package # GPU support
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package # 4.3生成whl文件
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg # 5 安装刚刚编译好的pip 包
# 这里安装的时候官方文档使用的是sudo命令,如果是个人电脑,不建议使用sudo, 直接pip即可。
$ pip install /tmp/tensorflow_pkg/tensorflow-{version}-none-any.whl # 6 接下来就是验证你是否已经安装成功
$ python -c "import tensorflow as tf; print(tf.Session().run(tf.constant('Hello, TensorFlow')))"
# 然后你就会看到如下输出
b'Hello, TensorFlow' # 恭喜你,成功编译了tensorflow,Warning也都解决了!

报错解决

Do you wish to build TensorFlow with MKL support? [y/N] y
MKL support will be enabled for TensorFlow
Do you wish to download MKL LIB from the web? [Y/n] y
Darwin is unsupported yet
# 这里MKL不支持Darwin(MAC),因此要选择N ERROR: /Users/***/Documents/tensorflow/tensorflow/core/BUILD:1331:1: C++ compilation of rule '//tensorflow/core:lib_hash_crc32c_accelerate_internal' failed: cc_wrapper.sh failed: error executing command external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 32 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
clang: error: no such file or directory: 'y'
clang: error: no such file or directory: 'y' # 这里是因为在configure的时候有些包不支持但是选择了y,因此记住一点所有的都选n

转载:https://www.jianshu.com/p/b1faa10c9238

TensorFlow CPU环境 SSE/AVX/FMA 指令集编译的更多相关文章

  1. Tensorflow Cpu不支持AVX

    Tensorflow从1.6开始从AVX编译二进制文件,所以如果你的CPU不支持AVX 你需要 从源码编译 下载旧版 从源码编译比较麻烦,如果你是初学的话,我建议使用旧版. 安装旧版: pip3 in ...

  2. 编译TensorFlow CPU指令集优化版

    编译TensorFlow CPU指令集优化版 如题,CPU指令集优化版,说的是针对某种特定的CPU型号进行过优化的版本.通常官方给的版本是没有针对特定CPU进行过优化的,有网友称,优化过的版本相比优化 ...

  3. centos7 源码编译安装TensorFlow CPU 版本

    一.前言 我们都知道,普通使用pip安装的TensorFlow是万金油版本,当你运行的时候,会提示你不是当前电脑中最优的版本,特别是CPU版本,没有使用指令集优化会让TensorFlow用起来更慢. ...

  4. 深度学习(TensorFlow)环境搭建:(三)Ubuntu16.04+CUDA8.0+cuDNN7+Anaconda4.4+Python3.6+TensorFlow1.3

    紧接着上一篇的文章<深度学习(TensorFlow)环境搭建:(二)Ubuntu16.04+1080Ti显卡驱动>,这篇文章,主要讲解如何安装CUDA+CUDNN,不过前提是我们是已经把N ...

  5. Ubuntu 16.04 TensorFlow CPU 版本安装

    1.下载Anaconda,官方网站.我下载的时Python 2.7 64bit版本: 2.安装执行命令     bash Anaconda2-4.2.0-Linux-x86_64.sh 设置好目录后等 ...

  6. TensorFlow实验环境搭建

    初衷: 由于系统.平台的原因,网上有各种版本的tensorflow安装教程,基于linux的.mac的.windows的,各有不同,tensorflow的官网也给出了具体的安装命令.但实际上,即使te ...

  7. 深度学习Tensorflow生产环境部署(下·模型部署篇)

    前一篇讲过环境的部署篇,这一次就讲讲从代码角度如何导出pb模型,如何进行服务调用. 1 hello world篇 部署完docker后,如果是cpu环境,可以直接拉取tensorflow/servin ...

  8. 虚拟机 Ubuntu18.04 tensorflow cpu 版本

    虚拟机 Ubuntu18.04 tensorflow cpu 版本 虚拟机VMware 配置: 20G容量,可扩充 2G内存,可扩充 网络采用NAT模式 平台:win10下的Ubuntu18.04 出 ...

  9. Windows下Anaconda安装 python + tensorflow CPU版

    下载安装Anaconda 首先下载Anaconda,可以从清华大学的镜像网站进行下载. 安装Anaconda,注意安装时不要将添加环境变量的选项取消掉. 安装完成之后,在安装目录下cmd,输入: co ...

随机推荐

  1. LGOJ1290 欧几里德的游戏

    题目链接 P1290 and UVA10368 (双倍经验[虽然标签差距很有趣]) 题目大意 给定两个数\(n\)和\(m\),每次操作可以用较大数减去较小数的正整数倍,不可以减成负数. 先获得一个\ ...

  2. ArcGIS自定义坐标变换中的方法说明

    在10.1里面,一共提供了12种转换的方法,如下: Ø  Geocentric_Translation Ø  Molodensky Ø  Molodensky_Abridged Ø  Position ...

  3. 吴裕雄--天生自然 HADOOP大数据分布式处理:使用XShell远程连接主机与服务器并配置它们之间SSH免密登录

  4. python后端面试第七部分:项目部分--长期维护

    ##################    项目部分       ####################### 1,你怎么测试自己的代码的?自测 2,开发使用windows还是Linux,虚拟环境的 ...

  5. 乐观锁(Optimistic Lock)

    乐观锁(非阻塞)指不通过锁表来解决并发问题,一般情况下表数据都会加入一个version字段,对该字段进行比较更新来保证数据的一致性. 这里写了个demo,应该可以说明乐观锁的问题. public cl ...

  6. labview学习——生产者/消费者(数据)(事件)

    其主要的模型: 主要从以下几个方面理解: 1.可重入性 正常的labview是多线程设计语言,而我们在执行VI时的规则是通过VI的命名来分别调用实现的. 打开VI的Highlight调试工具,可以看出 ...

  7. 微信小游戏排行榜页滚动查看排行榜(canvas指定区域溢出滚动,懒渲染)

    在微信小游戏中,好友排名数据是能在关系数据域操作,整个关系数据域只会返回一个最终的sharedCanvas,并且这个canvas不能调用toDataURL()方法,所以要展示好友排行榜的话只能在关系数 ...

  8. openpyxl操作excel表格

    1.openpyxl 只支持打开.xlsx格式,其他excel类库基本也是 2.不能这里的工作面板直接右键新建表格,必须到文件夹下面去新建,可以把在别的目录新建的表格直接复制到当前目录下 3.从表格中 ...

  9. MyBatis like (模糊查询)

    select * from user where user_name like concat('%',#{userName},'%'); select * from user where user_n ...

  10. 吴裕雄--天生自然KITTEN编程:小鼠数学题