ubuntu16.04 源码方法安装tensorflow
参考博客:http://blog.csdn.net/zhaoyu106/article/details/52793183/,
http://blog.csdn.net/u010900574/article/details/52201808
由于我之前已经配置过cuda8.0和cudnn5.1.10所以不用安装了
1、安装bazel
点击链接: installer for your system,跳转到Bazel的下载页面:
下载bazel-0.7.0-installer-linux-x86_64.sh到桌面,下载最新版的,不用和我的一致,然后在terminal中输入以下命令
- cd /home/***(自己的用户名)/Desktop/###(这个命令意思是找到刚刚我们用U盘传过来的文件)
- chmod +x PATH_TO_INSTALL.SH #对.sh文件授权
- ./PATH_TO_INSTALL.SH --user #运行.sh文件
2、安装第三方库
在terminal中输入以下命令
- sudo apt-get install python-numpy swig python-dev python-wheel #安装第三方库
- sudo apt-get install git
- git clone git://github.com/numpy/numpy.git numpy
3、安装tensorflow
在terminal中输入以下命令
- git clone https://github.com/tensorflow/tensorflow
在terminal中输入以下命令:
- cd ~/tensorflow #切换到tensorflow文件夹
- ./configure #执行configure文件
- 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/lib/python2.7/site-packages
- /usr/lib64/python2.7/site-packages
- Please input the desired Python library path to use. Default is [/usr/lib/python2.7/site-packages]
- Using python library path: /usr/lib/python2.7/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] y
- CUDA support will be enabled for TensorFlow
- Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
- Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0
- Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-8.0
4、创建pip
在tensorflow的根目录下,在terminal中输入以下命令:
- bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
- bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
- bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
- sudo pip install /home/***(你自己的用户名)/Desktop/tensorflow-0.10.0-cp2-none-any.whl
tensorflow-0.10.0-cp2-none-any.whl要根据你下载的文件名有所更改。
5、设置tensorflow环境
- bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
- # To build with GPU support:
- bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
- mkdir _python_build
- cd _python_build
- ln -s ../bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/* .
- ln -s ../tensorflow/tools/pip_package/* .
- python setup.py develop
6、tensorflow测试
- $ python
- >>> import tensorflow as tf
- >>> hello = tf.constant('Hello, TensorFlow!')
- >>> sess = tf.Session()
- >>> print sess.run(hello)
- Hello, TensorFlow!
- >>> a = tf.constant(10)
- >>> b = tf.constant(32)
- >>> print sess.run(a+b)
- 42
- >>>
大功告成
出现的错误
操作
- bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainer
报错
- ERROR: /home/yaroslavvb/tensorflow.git/tensorflow/tensorflow/core/kernels/BUILD:1080:1: undeclared inclusion(s) in rule '//tensorflow/core/kernels:cwise_op_gpu':
- this is missing dependency dependency for following files included by 'tensorflow/core/kernels/cwise_op_gpu_floor.cu.cc':
- '/usr/local/cuda-8.0/include/cuda_runtime.h'
- '/usr/local/cuda-8.0/include/host_config.h'
- '/usr/local/cuda-8.0/include/builtin_types.h'
- '/usr/local/cuda-8.0/include/device_types.h'
- '/usr/local/cuda-8.0/include/host_defines.h'
- '/usr/local/cuda-8.0/include/driver_types.h'
- '/usr/local/cuda-8.0/include/surface_types.h'
- '/usr/local/cuda-8.0/include/texture_types.h'
可以进入tensorflow/third_party/gpus/crosstool/目录,打开CROSSTOOL文件,搜索cxx_builtin_include_directory,应该有三行,在下面添加行如下
cxx_builtin_include_directory: "/usr/local/cuda-8.0/include"
如果出现的错误是类似的,只要将cxx_builtin_include_directory: "/usr/local/cuda-8.0/include"
的文件路径改一下就可以了,亲测有效
再次运行上一步的命令,应该就没问题了。
ubuntu16.04 源码方法安装tensorflow的更多相关文章
- ubuntu16.04源码编译安装wine1.8.6安装不上引来的错误
configure: libxcomposite 64-bit development files not found, Xcomposite won't be supported. configur ...
- ubuntu16.04源码编译安装nginx1.14.2
1.下载nginx-1.14.2, 官网地址:nginx.org 2.解压nginx-1.14.2.tar.gz tar zxvf nginx-1.14.2.tar.gz 3.切到文件夹nginx-1 ...
- [笔记] Ubuntu 18.04源码编译安装OpenCV 4.0流程
标准常规安装方法安装的OpenCV版本比较低,想尝鲜使用4.0版本,只好源码安装. 安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 CUDA:10.0 c ...
- centos7 源码编译安装TensorFlow CPU 版本
一.前言 我们都知道,普通使用pip安装的TensorFlow是万金油版本,当你运行的时候,会提示你不是当前电脑中最优的版本,特别是CPU版本,没有使用指令集优化会让TensorFlow用起来更慢. ...
- ubuntu16.04 源码安装Python3.7 (可以在此基础上安装Tensorflow) (确保Tensorflow计算框架与系统的彻底隔离)
Python3.7 源码下载: https://www.python.org/downloads/release/python-370/ 解压源码: tar -zxvf Python-3.7.0.tg ...
- windows10下如何进行源码编译安装tensorflow
1.获取python3.5.x https://www.python.org/ftp/python/3.5.4/python-3.5.4-amd64.exe 2.安装python3.5.x,默认安装即 ...
- Ubuntu 16.04 源码编译安装PHP7+swoole
备注: Ubuntu 16.04 Server 版安装过程图文详解 Ubuntu16镜像地址: 链接:https://pan.baidu.com/s/1XTVS6BdwPPmSsF-cYF6B7Q 密 ...
- Mac下使用源码编译安装TensorFlow CPU版本
1.安装必要的软件 1.1.安装JDK 8 (1)JDK 8 can be downloaded from Oracle's JDK Page: http://www.oracle.com/techn ...
- Ubuntu 16.04 源码编译安装PHP7
一.下载PHP7的最新版源码 php7.0.9 下载地址 http://php.net/get/php-7.0.9.tar.gz/from/a/mirror 二.解压 tar -zxf /tmp/p ...
随机推荐
- 字符串(string)与整型(int)、浮点型(float)等之间的转换
#include <stdlib.h> 1.int/float to string/array: C语言提供了几个标准库函数,可以将任意类型(整型.长整型.浮点型等)的数字转换为字符串,下 ...
- c++11 左值引用、右值引用
c++11 左值引用.右值引用 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #i ...
- 从商用到开源:15个维度,全面剖析DB2与MySQL数据库的差异
随着MySQL数据库的应用越来越广泛,DB2向MySQL数据库的迁移需求也越来越多.进行数据库之间迁移的时候,首先遇到的并且也是最基本最重要的就是两种数据库数据类型之间的转换. 相关阅读: 从商用到开 ...
- easyui的datebox只显示年月
要求点击easyui的datebox时只显示年月,隐藏日,之前百度了好多,发现有的好麻烦,有的使用没效果,也许自己没理解,改不了.最后老员工帮我搞定了,添加一个fomatter和一个parser函数就 ...
- 20135319zl字符集报告
字符集实验 ASCII 首先,查找ZHULI五个字符对应的ASCII码,5a 48 55 4c 49. 然后,用vim打开一个空文档,按下":",输入%!xxd 然后,输入 000 ...
- 压测工具-Jmeter
server压力测试首选: Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域. 1 JMet ...
- 深度学习网络层之 Pooling
pooling 是仿照人的视觉系统进行降维(降采样),用更高层的抽象表示图像特征,这一部分内容从Hubel&wiesel视觉神经研究到Fukushima提出,再到LeCun的LeNet5首次采 ...
- faster rcnn算法及源码及论文解析相关博客
1. 通过代码理解faster-RCNN中的RPN http://blog.csdn.net/happyflyy/article/details/54917514 2. faster rcnn详解 R ...
- Docker swarm 使用服务编排部署lnmp
一.简介 目的:在Docker Swarm集群中,使用stack服务编排搭建lnmp来部署WordPress 使用私有仓库的nginx和php镜像 mysql使用dockerhup最新镜像 使用nfs ...
- python的内置模块time和datetime的方法详解以及使用(python内的time和datetime时间格式)
time内置模块的方法 1.time() 时间戳 time() -> floating point number 浮点数 Return the current time in seconds ...