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. 关于 SQLServer Express 2012 的连接字符串

    调试的时候,使用的是 LocalDB,SqlConnection 的连接字符串很简单 Data Source=(localdb)\ProjectsV12;Initial Catalog=master; ...

  2. python爬虫和数据分析、数据挖掘

    一.python爬虫脑图: 二.python爬虫流程: 三.python数据分析简介 四.python数据预处理方法 五.python数据挖掘 六.数据探索基础

  3. Navicat 12 无限期试用

    最近发现navicat12又过期了,以前的是用的破解软件,然后是到1899年过期哈哈哈哈哈哈.重装了系统后,软件也重装了,发现破解软件不好使了,就先试用了,现在到期了.很是难受,这可咋整,不过在网上看 ...

  4. “pip install tensorflow ”出现错误

    在控制台命令窗口输入:pip install tensorflow之后出现一长串bug怎么解决 网上百度了一些方法: 安装Python3.5 安装Python3.6 总结原因:Python3.7没有合 ...

  5. Qt error C2338: No Q_OBJECT in the class with the signal错误解决办法(无法编译过信号与槽)

    由于没有继承QObject类而引起的 只需继承QObject类即可 如果已经继承了QObject类,编译还出现错误 将QObject类放在最前面继承:public QObject 最后即可编译通过

  6. TensorFlow 介绍

    关于 TensorFlow TensorFlow™ 是一个采用数据流图(data flow graphs),用于数值计算的开源软件库.节点(Nodes)在图中表示数学操作,图中的线(edges)则表示 ...

  7. 以elasticsearch-hadoop 向elasticsearch 导数,丢失数据的问题排查

    实际这是很久之前的问题了,当时没时间记录 这里简单回顾 项目基于 数据架构不方便说太细,最精简的 somedata-> [kafka]->spark-stream->elastics ...

  8. Factual question|具体特殊

    Factual question:答案一定出于文章,不是总结 流程:找定位词做连连看,找对定位词,先看此句,然后看选项回文对照.如果找不到找上下两句话. 为了缩小范围,定位词是具体特殊,不要抽象词,可 ...

  9. ORs-6-Olfactory Bulb Ratio, ORs Gene Repertoire, and Olfactory Ability

    Olfactory Bulb Ratio, ORs Gene Repertoire, and Olfactory Ability 1.Olfactory Bulb的生物学意义:a.生存 b.嗅觉能力 ...

  10. 图形学创世纪——写在SIGGRAPH 40年的边上

    40年的边上" title="图形学创世纪--写在SIGGRAPH 40年的边上"> 前言: SIGGRAPH是由ACM SIGGRAPH(美国计算机协会计算机图形 ...