How to compile tensorflow on CentOS
Tensorflow is a very effective machine learning library implemented by C++, we can use tensorflow with Python, but, there is a problem if we don't compile the tensorflow, it would cost a lot of time to compute. when we install the tensorflow with pip, we can see a warning message:"The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations." when import tensorflow. so, we need to compile the tensorflow library to speed up computation.
What to prepare:
- Java 8
- Bazel
- Tensorflow
- Python 3+
- CuDNN and CUDA toolkit(if you want to build tensorflow-gpu version)
Install Bazel:
- check you JAVA_HOME or test java: $ java -version
- get Bazel package: $ git clone https://github.com/bazelbuild/bazel.git (bazel can't install with yum.)
- switch to a proper version: $ git checkout tags/0.3.0
- $ cd bazel
- $ ./compile.sh
- add bazel to PATH for convenient: $ PATH = $PATH:(PATH_TO_BAZEL)/output/
Tensorflow:
- get Tensorflow package: $ git clone https://github.com/tensorflow/tensorflow
- $ cd tensorflow
configure
./configurePlease specify the location of python. [Default is /usr/bin/python]: /home/xxxx/.pyenv/version/python36/bin/pythonPlease specify optimization flags to use during compilation when bazel option"--config=opt"is specified [Default is -march=native]:Do you wish to use jemalloc as the malloc implementation? [Y/n] Yjemalloc enabledDo you wish to build TensorFlow with Google Cloud Platform support? [y/N] NNo Google Cloud Platform support will be enabledforTensorFlowDo you wish to build TensorFlow with Hadoop File System support? [y/N] NNo Hadoop File System support will be enabledforTensorFlowDo you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] NNo XLA JIT support will be enabledforTensorFlowFound possible Python library paths:/usr/local/lib/python2.7/dist-packages/usr/lib/python2.7/dist-packagesPlease input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]Using python library path: /home/xxxx/.pyenv/version/python36/lib/python3.6/site-packagesDo you wish to build TensorFlow with OpenCL support? [y/N] NNo OpenCL support will be enabledforTensorFlowDo you wish to build TensorFlow with CUDA support? [y/N] NConfiguration finished- build tensorflow with bazel: $ bazel build -c opt --copt=-msse4.1 --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package
- build whl file: $ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
- install tensorflow with whl file: $ pip install --upgrade /tmp/tensorflow_pkg/<your whl file>.whl
#Troubleshotting
After installing tensorflow with whl file, if you get an error with message "illegal instruction", that may caused by you use unsupported sse to build tensorflow, AVX, SSE4.1, SSE4.2, MFA are different kinds of extended instruction sets on X86 CPUs. Many contain optimized instructions for processing matrix or vector operations. before installing, check which instructions your CPU support, and put those optimizing flags in for all.
$ bazel build -c opt --copt=-mavx --copt=-msse4.1 --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package
This solution refer to: https://github.com/tensorflow/tensorflow/issues/8976
How to compile tensorflow on CentOS的更多相关文章
- 【转】Compile FFmpeg on CentOS 6.x
This guide is based on a minimal CentOS installation and will install FFmpeg with several external e ...
- CentOS 6 编译 TensorFlow for Java 以及 Maven Pom
我们的系统环境 CentOS 6.5, JDK 1.8 更新yum源 $ yum update 安装 Python 2.7 $ yum install python27 python27-numpy ...
- centos上tensorflow一键安装脚本
鉴于tensorflow在centos上安装相当麻烦,特地制作了一个脚本方便以后移植到其它机器上,脚本含有其它python常用包: #! /bin/bash sudo yum install -y ...
- Ubuntu TensorFlow 源码 Android Demo的编译运行
Ubuntu TensorFlow 源码 Android Demo的编译运行 一. 安装 Android 的SDK和NDK SDK 配置 A:下载 国内下载地址选最新的: SDK: https://d ...
- TensorFlow Android Camera Demo 使用android studio编译安装和解决Execution failed for task ':buildNativeBazel'报错
可以参考官网:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android#android-stud ...
- Tensorflow[目录结构]
1 - Tensorflow源码目录结构 基于2018年5月28日github的tensorflow源码,即1.8版本 第一层: tensorflow: 核心代码目录. third_party:第三方 ...
- centos7 源码编译安装TensorFlow CPU 版本
一.前言 我们都知道,普通使用pip安装的TensorFlow是万金油版本,当你运行的时候,会提示你不是当前电脑中最优的版本,特别是CPU版本,没有使用指令集优化会让TensorFlow用起来更慢. ...
- How to install tensorflow from source on ubuntu 18.04 64bit
1,install dependencies sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy py ...
- TensorFlow编译androiddemo
首先是把tensorflow克隆到本地一份. git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git 既 ...
随机推荐
- android获取Context
如果在Activity方法中,直接使用this. 如果在Activity内部类中,使用Activity.this
- Golang微服务:micro实践
micro 使用 工具安装 使用protoc生成代码,依赖两个插件:protoc-gen-go.protoc-gen-micro micro 工具 go get -u github.com/micro ...
- 在CMD命令下安装nexus报错和启动的问题
安装问题问题描述: 在控制台(cmd)下执行nexus install命令安装nexus服务的时候报错: wrapper | OpenSCManager failed - 拒绝访问. (0x5) 同时 ...
- Java I/O输入输出流
IO流的复习总结 ------注:蓝色背景段落是例子:红色背景的字段IO流的功能类. 编码问题 String s = "威力锅ABC"; //utf-8编码中文占用三个字节,英文 ...
- 19. Rootkit detectors (隐形工具包检测器 5个)
Sysinternals提供了许多小型Windows实用程序,对于低级别的Windows黑客攻击来说非常有用. 一些是免费的和/或包括源代码,而其他是专有的. 调查受访者最喜欢:ProcessExpl ...
- java数据结构之链表(java核心卷Ⅰ读书笔记)
1.链表 数组和ArrayList的一个重大缺陷就是:从中间位置删除一个元素要付出很大的代价,因为在这个元素删除之后,所有的元素都要向前端移动,在中间的某个位置插入一个元素也是这个原因. (小感悟:s ...
- bookmarks
嵌入式/硬件/计算机原理 PCI ID的分配 ARM汇编指令介绍 (连续4篇) https://blog.csdn.net/makethyme/article/details/1641413https ...
- Java泛型相关总结(下)
约束与局限性 不能用基本类型实例化类型参数 不能像Pair<double>这样调用,只能Pair<Double>,原因是类型擦除 运行时类型查询只使用于原始类型 虚拟机中的对象 ...
- 剑指offer 9.递归和循环 变态跳台阶
题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 这道题还是编程题? 数学渣渣看到心拔凉拔凉的, 要用到数学归纳法来 ...
- rocketmq 4.3.2 解决远程不能消费问题,解决未识别到公网IP问题
1.解决远程不能消费问题 问题描述: nameserver和broker启动后,用tools(命令如下)能发送消息和消费消息,在局域网服务器能发送消息,消费启动后收不到消息通知问题 sh tools. ...