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 既 ...
随机推荐
- PC端的软件端口和adb 5037端口冲突解决方案
引用https://www.aliyun.com/jiaocheng/32552.html 阿里云 > 教程中心 > android教程 > PC端的软件端口和adb 50 ...
- HBase原理和设计
转载 2016年1月10日:http://www.sysdb.cn/index.php/2016/01/10/hbase_principle/ 简介 架构 数据组织 原理 RS定位 region写入 ...
- crunch--字典生成工具
Crunch是一种创建密码字典工具,按照指定的规则生成密码字典,可以灵活的制定自己的字典文件.使用Crunch工具生成的密码可以输出到屏幕,保存到文件.或另一个程序.crunch程序在2004年及以前 ...
- complex类的设计实现
#include <iostream> #include <cmath> using namespace std; class Complex{ ,); Complex(Com ...
- ms16-032漏洞复现过程
这章节写的是ms16-032漏洞,这个漏洞是16年发布的,版本对象是03.08和12.文章即自己的笔记嘛,既然学了就写下来.在写完这个漏洞后明天就该认真刷题针对16号的比赛了.Over,让我们开始吧! ...
- Scrum学习心得
一.Scrum学习心得: 最近简单的学习了一下scrum模式,感觉又开启了一个新世界的大门. 首先,scrum是一个应用于互联网研发的开发方式,这种开发方式的主要特点是快速迭代,持续交付. scrum ...
- java反射2
package com.wen; import java.lang.reflect.Field;import java.lang.reflect.Method; public class Test2 ...
- 使用maven整合spring+springmvc+mybatis
使用maven整合spring+springmvc+mybatis 开发环境: 1. jdk1.8 2. eclipse4.7.0 (Oxygen) 3. mysql 5.7 在pom.xml文件中, ...
- [Java Web学习]junit.framework.AssertionFailedError: No tests found in {Class}
No tests found in com.XXXXX.XXX.inboundPrepService.bizLogic.prepDeterminationEngine.workers.Determin ...
- influxdb 全家桶运行
一个简单的demo,集成了telegraf,influxdb,chronograf,kapacitor,nginx,一张来自官方的参考图 组件集成图 环境准备 使用docker-compose doc ...