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 既 ...
随机推荐
- linux终端窗口字体缩放快捷键
环境:ubuntu16.04, 打开终端,有时候log输出一行显示不下 ‘ctrl’ + ‘-’字体缩小,一行显示更多的内容 ‘ctrl’ + ‘shift’ + ‘+’字体变大
- Linux系统环境下Tomcat8、httpd、mysql8开机自启动配置
Linux系统环境下Tomcat8.httpd.mysql8开机自启动配置: 相关命令:chkconfig 参考链接:https://jingyan.baidu.com/article/6525d4b ...
- appscan使用教程(全)
链接图文来源:https://www.cnblogs.com/ZoeLiang/p/10198361.html 一.下载与破解 1.下载Appscan:http://download2.boulder ...
- Python中的变量作用域
python中变量作用域包括: L (Local) 局部作用域,函数内部声明但没有使用global的变量E (Enclosing) 闭包函数外的函数中,def或者lambda的本地作用域G (Glob ...
- Python学习笔记–Chapter 2
1.字符串中添加制表符,可使用字符组合\t 2.字符串中添加换行符,可使用字符组合\n 3.字符串\n\t可以换到下一行,并且在开头添加一个制表符. 4.删除末尾空白,使用方法rstrip() 5.删 ...
- .net第四章内容总结
4.2) mdi 多文档界面 创建子窗体的childForm.text书上的做法childformnumber不存在 于是我自定义一个childforNumber起始为1: 在窗体下面显示所有已经 ...
- 阿里云ECS Centos7 系统安装图形化桌面
阿里云官网默认的Linux Centos7系统镜像,都是没有安装桌面环境的,用户如果要使用桌面,需要自己在服务器上进行安装. 本教程以MATE桌面安装为例 1.登录服务器,执行命令安装桌面环境. 先安 ...
- CentOS 7安全加固
本次实验使用的centos 7 版本 一.查找系统中是否存在空密码账户 1.使用命令: awk -F: '($2==""){print $1}' /etc/shadow 直接查看. ...
- 【开发】iOS入门 - Touch事件处理学习笔记
网上介绍iOS事件机制的文章,有不少都讲得很好,搬运一次意义不大,这里我就列一些要点吧. 跟Android一样,iOS的Touch事件也是从外到内传递,然后从内到外响应,可以看成一个U型结构.然而,个 ...
- vue---条件与循环语句
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta name=& ...