安装tensorflow

摘要:
使用VirtualenvInstallpipandVirtualenv通过发出以下新命令进行安装:$sudoapt getinstallpython pippython devpython virtualenv#forPython2.7$sudoapt-getinstallpython3-ppython3-devpython-v

Installing with Virtualenv

  1. Install pip and Virtualenv by issuing one of the following commands:

     
    $ sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7
    $ sudo apt-get install python3-pip python3-dev python-virtualenv # for Python 3.n
  2. Create a Virtualenv environment by issuing one of the following commands:

     
    $ virtualenv --system-site-packages targetDirectory # for Python 2.7
    $ virtualenv --system-site-packages -p python3 targetDirectory # for Python 3.n

    where targetDirectory specifies the top of the Virtualenv tree. Our instructions assume that targetDirectory is ~/tensorflow, but you may choose any directory.

  3. Activate the Virtualenv environment by issuing one of the following commands:

     
    $ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
    $ source ~/tensorflow/bin/activate.csh  # csh or tcsh

    The preceding source command should change your prompt to the following:

     
    (tensorflow)$ 
  4. Ensure pip ≥8.1 is installed:

     
    (tensorflow)$ easy_install -U pip
  5. Issue one of the following commands to install TensorFlow in the active Virtualenv environment:

     
    (tensorflow)$ pip install --upgrade tensorflow      # for Python 2.7
    (tensorflow)$ pip3 install --upgrade tensorflow     # for Python 3.n
    (tensorflow)$ pip install --upgrade tensorflow-gpu  # for Python 2.7 and GPU
    (tensorflow)$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU

    If the above command succeeds, skip Step 6. If the preceding command fails, perform Step 6.

  6. (Optional) If Step 5 failed (typically because you invoked a pip version lower than 8.1), install TensorFlow in the active Virtualenv environment by issuing a command of the following format:

     
    (tensorflow)$ pip install --upgrade tfBinaryURL   # Python 2.7
    (tensorflow)$ pip3 install --upgrade tfBinaryURL  # Python 3.n 

    where tfBinaryURL identifies the URL of the TensorFlow Python package. The appropriate value of tfBinaryURLdepends on the operating system, Python version, and GPU support. Find the appropriate value for tfBinaryURL for your system here. For example, if you are installing TensorFlow for Linux, Python 3.4, and CPU-only support, issue the following command to install TensorFlow in the active Virtualenv environment:

     
    (tensorflow)$ pip3 install --upgrade 
     https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.6.0-cp34-cp34m-linux_x86_64.whl

If you encounter installation problems, see Common Installation Problems.

Next Steps

After installing TensorFlow, validate the installation.

Note that you must activate the Virtualenv environment each time you use TensorFlow. If the Virtualenv environment is not currently active, invoke one of the following commands:

 
 $ source ~/tensorflow/bin/activate      # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh  # csh or tcsh

When the Virtualenv environment is active, you may run TensorFlow programs from this shell. Your prompt will become the following to indicate that your tensorflow environment is active:

 
(tensorflow)$ 

When you are done using TensorFlow, you may deactivate the environment by invoking the deactivate function as follows:

 
(tensorflow)$ deactivate 

The prompt will revert back to your default prompt (as defined by the PS1 environment variable).

Uninstalling TensorFlow

To uninstall TensorFlow, simply remove the tree you created. For example:

 
$ rm -r targetDirectory 

nstalling with native pip

You may install TensorFlow through pip, choosing between a simple installation procedure or a more complex one.

Note: The REQUIRED_PACKAGES section of setup.py lists the TensorFlow packages that pip will install or upgrade.

Prerequisite: Python and Pip

Python is automatically installed on Ubuntu. Take a moment to confirm (by issuing a python -V command) that one of the following Python versions is already installed on your system:

  • Python 2.7
  • Python 3.4+

The pip or pip3 package manager is usually installed on Ubuntu. Take a moment to confirm (by issuing a pip -V or pip3 -V command) that pip or pip3 is installed. We strongly recommend version 8.1 or higher of pip or pip3. If Version 8.1 or later is not installed, issue the following command, which will either install or upgrade to the latest pip version:

 
$ sudo apt-get install python-pip python-dev   # for Python 2.7
$ sudo apt-get install python3-pip python3-dev # for Python 3.n

Install TensorFlow

Assuming the prerequisite software is installed on your Linux host, take the following steps:

  1. Install TensorFlow by invoking one of the following commands:

     
    $ pip install tensorflow      # Python 2.7; CPU support (no GPU support)
    $ pip3 install tensorflow     # Python 3.n; CPU support (no GPU support)
    $ pip install tensorflow-gpu  # Python 2.7;  GPU support
    $ pip3 install tensorflow-gpu # Python 3.n; GPU support 

    If the preceding command runs to completion, you should now validate your installation.

  2. (Optional.) If Step 1 failed, install the latest version of TensorFlow by issuing a command of the following format:

     
    $ sudo pip  install --upgrade tfBinaryURL   # Python 2.7
    $ sudo pip3 install --upgrade tfBinaryURL   # Python 3.n 

    where tfBinaryURL identifies the URL of the TensorFlow Python package. The appropriate value of tfBinaryURL depends on the operating system, Python version, and GPU support. Find the appropriate value for tfBinaryURL here. For example, to install TensorFlow for Linux, Python 3.4, and CPU-only support, issue the following command:

     
     $ sudo pip3 install --upgrade 
     https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.6.0-cp34-cp34m-linux_x86_64.whl
     

    If this step fails, see Common Installation Problems.

Next Steps

After installing TensorFlow, validate your installation.

Uninstalling TensorFlow

To uninstall TensorFlow, issue one of following commands:

 
$ sudo pip uninstall tensorflow  # for Python 2.7
$ sudo pip3 uninstall tensorflow # for Python 3.n


免责声明:文章转载自《安装tensorflow》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇R语言对NASA元数据进行文本挖掘的主题建模分析Nginx internal 指令限制访问图片资源文件下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Python模块学习filecmp文件比较

Python模块学习filecmp文件比较 filecmp模块用于比较文件及文件夹的内容,它是一个轻量级的工具,使用非常简单。python标准库还提供了difflib模块用于比较文件的内容。关于difflib模块,且听下回分解 filecmp定义了两个函数,用于方便地比较文件与文件夹:  filecmp.cmp(f1, f2[, shallow]...

Objective-C调用Swift

如果已经有了一个老的iOS应用,它是使用Objective-C编写的,而它的一些新功能需要采用Swift来编写,这时就可以从Objective-C调用Swift。 Objective-C调用Swift时不需要桥接头文件,而是需要Xcode生成的头文件。这种文件由Xcode生成,不需要我们维护,对于开发人员也是不可见的。如下图所示,它能够将Swift中的类暴...

【Python】批量查询-提取站长之家IP批量查询的结果加强版本v3.0

1、工具说明 写报告的时候为了细致性,要把IP地址对应的地区给整理出来。500多条IP地址找出对应地区复制粘贴到报告里整了一个上午。 为了下次更好的完成这项重复性很高的工作,所以写了这个小的脚本。 某个项目每次改需求都是这么突然。 应 XX 每天要求各种省份域名统计,再加强下Domain to IP to 地区的脚本。 Domain2ip2locality...

python 函数返回值(总结)

  关键字:return   没有返回值的叫过程 def test1(): msg="我是一个过程" print(msg) 有return的叫函数 def test02(): msg="我是函数,有返回值" print(msg) return msg 关于返回的值: 定义的函数可以返回多个值,组合成元组def test03()...

使用原生 python 造轮子搭建博客

这篇用来 记录一个 从零开始的 博客搭建,希望坚持下去,因为python 开发效率令人发指,所以会原生从零写 ORM ,Web 框架 前提是打好 异步 io 的基础, 使用异步,有一点要谨记,一旦开始异步,层层异步,从 http 到 数据库层都要用异步框架写异步函数,所谓开弓没有回头箭 # -*- coding: utf-8 -*- import asy...

吾八哥学Selenium(四):操作下拉框select标签的方法

我们在做web页面自动化测试的时候会经常遇到<select></select>标签的下拉框,那么在Python里如何实现去操作这种控件呢?今天就给大家分享一下这个玩法。为了让大家学习更方便,我准备了一个测试页面。 测试的html页面代码为: <html> <head> <title>学Python...