zoukankan      html  css  js  c++  java
  • 安装tensorflow

    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


    
    
  • 相关阅读:
    kubernetes系列(十四)
    kubernetes系列(十三)
    kubernetes系列(十二)
    kubernetes系列(十一)
    kubernetes系列(十)
    kubernetes系列(九)
    kubernetes系列(八)
    MySQL命令(其三)
    MySQL操作命令(其二)
    MySQL命令(其一)
  • 原文地址:https://www.cnblogs.com/CATHY-MU/p/8526961.html
Copyright © 2011-2022 走看看