zoukankan      html  css  js  c++  java
  • tensorflow源代码方式安装

      本文介绍tensorflow源代码方式安装。安装的系统为 Ubuntu 15.04。

    获取TensorFlow源代码

    git clone --recurse-submodules https://github.com/tensorflow/tensorflow
    

    使用 --recurse-submodules 选项来获取 TensorFlow 需要依赖的 protobuf 库文件。

    安装 Bazel

      遵从以下 指令 来安装 bazel 依赖。bazel 安装文件:下载地址

      bazel 缺省需要使用JDK1.8,如你使用JDK1.7,请下载相应的安装包。

      安装 Bazel 其他所需依赖:

    sudo apt-get install pkg-config zip g++ zlib1g-dev unzip
    

      执行如下命令来安装Bazel:

    chmod +x PATH_TO_INSTALL.SH
    ./PATH_TO_INSTALL.SH --user
    

       记住把 PATH_TO_INSTALL.SH 替换为你下载的Bazel安装文件名,如:

    ./bazel-0.1.4-installer-linux-x86_64.sh  --user
    

    安装其他依赖

    sudo apt-get install python-numpy swig python-dev
    

    配置安装

      运行 tensorflow 根目录下的 configure 脚本。这个脚本会要求你输入 python 解释器的安装路径,并允许你可选择安装CUDA库。

      如果不安装CUDA,则这一步主要是定位python和numpy头文件所在位置:

    ./configure
    Please specify the location of python. [Default is /usr/bin/python]:
    

       如果要安装CUDA,则除了指定 python 外,还需指定 CUDA 安装位置:

    ./configure
    Please specify the location of python. [Default is /usr/bin/python]:
    Do you wish to build TensorFlow with GPU support? [y/N] y
    GPU support will be enabled for TensorFlow
    
    Please specify the location where CUDA 7.0 toolkit is installed. Refer to
    README.md for more details. [default is: /usr/local/cuda]: /usr/local/cuda
    
    Please specify the location where the cuDNN v2 library is installed. Refer to
    README.md for more details. [default is: /usr/local/cuda]: /usr/local/cuda
    
    Setting up Cuda include
    Setting up Cuda lib64
    Setting up Cuda bin
    Setting up Cuda nvvm
    Configuration finished
    

    构建支持GPU的Tensorflow 

      在tensorflow 根目录下执行如下命令:

    $ bazel build -c opt --config=cuda --spawn_strategy=standalone //tensorflow/cc:tutorials_example_trainer
    
    $ bazel-bin/tensorflow/cc/tutorials_example_trainer --use_gpu
    # Lots of output. This tutorial iteratively calculates the major eigenvalue of
    # a 2x2 matrix, on GPU. The last few lines look like this.
    000009/000005 lambda = 2.000000 x = [0.894427 -0.447214] y = [1.788854 -0.894427]
    000006/000001 lambda = 2.000000 x = [0.894427 -0.447214] y = [1.788854 -0.894427]
    000009/000009 lambda = 2.000000 x = [0.894427 -0.447214] y = [1.788854 -0.894427]

    Note that "--config=cuda" is needed to enable the GPU support.

  • 相关阅读:
    openssl之EVP系列之5---EVP_Encrypt系列函数具体解释(二)
    LINQ to SQL活学活用(1):这要打破旧观念
    【安卓】乾坤大罗移,将容器触摸事件传至还有一容器、!
    高速排序——JAVA实现(图文并茂)
    WebCollector爬取百度搜索引擎样例
    nyist 202 红黑树(二叉树中序遍历)
    excel转换日期格式,将yyyymmdd类型日期转换成yyyy-mm-dd等日期类型方法
    窗体界面设计03
    窗体界面设计02
    窗体界面设计01
  • 原文地址:https://www.cnblogs.com/simplelovecs/p/5150114.html
Copyright © 2011-2022 走看看