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
./configure
Please specify the location of python. [Default is /usr/bin/python]: /home/xxxx/.pyenv/version/python36/bin/python
Please 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] Y
jemalloc enabled
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N
No Google Cloud Platform support will be enabled
for
TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N] N
No Hadoop File System support will be enabled
for
TensorFlow
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] N
No XLA JIT support will be enabled
for
TensorFlow
Found possible Python library paths:
/usr/local/lib/python2.
7
/dist-packages
/usr/lib/python2.
7
/dist-packages
Please 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-packages
Do you wish to build TensorFlow with OpenCL support? [y/N] N
No OpenCL support will be enabled
for
TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N] N
Configuration 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 既 ...
随机推荐
- 二进制按位与(&) 按位或(|) 异或运算(^)
1.参加运算的两个数据,按照二进制进行按位与的运算. 运算规则:0&0=0; 0&1=0; 1&0=0; 1&1=1; 即:两位同时为“1”,结果才为 ...
- 小学生噩梦——四则运算题库(python 全功能实现)
Github: https://github.com/holidaysss 小组:龙天尧(代码实现),林毓植(浮点转分数函数,代码审查) PSP2.1 Personal Software Proces ...
- mysql数据库的增量备份和全备
还有一种简单的方法 参考 https://blog.csdn.net/u010098331/article/details/50932064 (注意:5.6版本以上新加了gtid 功能,gtid开启之 ...
- linux怎么实时查看目录下是否有文件生成
inotify-tools 是为linux下inotify文件监控工具提供的一套c的开发接口库函数,同时还提供了一系列的命令行工具,这些工具可以用来监控文件系统的事件. inotify-tools是用 ...
- MongoDB慢查询性能分析
最近,长期运营后的港台服出现一个问题,web充值很慢,用gm指令查询玩家信息也很慢.最后定位到MongoDB查询也很慢. 刚开始定位的时候,运营SA直接查指定的玩家,并反映很慢,就猜测是索引的问题 ...
- linux下tomcat的启动,停止,重启脚本
1.tomcat的启动脚本 #vi start_tomcat.sh pid=`ps -ef |grep tomcat |grep -v grep|awk '{print $2}'` ##定 ...
- JAVA for(i = 0; i<a.length; i++) 解析
下列 System.out.printf 语句输出的结果是什么? Char a[]={„a‟,‟b‟,‟c‟,‟d‟,‟e‟}; For(i=0; i<=a.length/2; i++) { c ...
- CF999E Reachability from the Capital来自首都的可达性
题目大意: 有n个节点m条边,边都是单向的,请你添加最少的边使得起点s到其他与其他每一个点之间都能互相到达 这题一看就是一个缩点啊 其实对于原有的m条边相连的一些点,如果之前他们已经形成了强连通分量( ...
- python练习题3:N的多次方
N的多次方 描述 编写一个程序,计算输入数字N的0次方到5次方结果,并依次输出这6个结果,输出结果间用空格分隔.其中:N是一个整数或浮点数. print()函数可以同时输出多个信息,采用如下方法可以使 ...
- docker WARNING: IPv4 forwarding is disabled. 解决方法
WARNING: IPv4 forwarding is disabled. Networking will not work. 在宿主机添加如下信息 echo net.ipv4.ip_forward= ...